From 5d5702b8c0bf756f111f157f8b5325ec32c0c1c3 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Fri, 12 Apr 2024 22:00:55 +0800 Subject: [PATCH] [server] Implement CGameMode functions --- server/gamemodes.cpp | 1172 ++++++++++++++++++++++++++++++++++++++++++ server/gamemodes.h | 57 ++ server/netgame.h | 1 + server/player.cpp | 9 + server/player.h | 2 + server/playerpool.h | 12 + 6 files changed, 1253 insertions(+) diff --git a/server/gamemodes.cpp b/server/gamemodes.cpp index fd815bd..c9881eb 100644 --- a/server/gamemodes.cpp +++ b/server/gamemodes.cpp @@ -146,4 +146,1176 @@ int CGameMode::CallPublic(char* szFuncName) //---------------------------------------------------------------------------------- +// forward OnPlayerConnect(playerid); +int CGameMode::OnPlayerConnect(cell playerid) +{ + CHECK_INIT(); + + int idx; + cell ret = 0; + + if (!amx_FindPublic(&m_amx, "OnPlayerConnect", &idx)) + { + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; } + +//---------------------------------------------------------------------------------- + +// forward OnPlayerDisconnect(playerid, reason); +int CGameMode::OnPlayerDisconnect(cell playerid, cell reason) +{ + //CHECK_INIT(); + + int idx; + cell ret = 0; + + if (!amx_FindPublic(&m_amx, "OnPlayerDisconnect", &idx)) + { + amx_Push(&m_amx, reason); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerSpawn(playerid); +int CGameMode::OnPlayerSpawn(cell playerid) +{ + CHECK_INIT(); + + int idx; + cell ret = 0; + + if (!amx_FindPublic(&m_amx, "OnPlayerSpawn", &idx)) + { + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerDeath(playerid, killerid, reason); +int CGameMode::OnPlayerDeath(cell playerid, cell killerid, cell reason) +{ + CHECK_INIT(); + + int idx; + cell ret = 0; + + if (!amx_FindPublic(&m_amx, "OnPlayerDeath", &idx)) + { + amx_Push(&m_amx, reason); + amx_Push(&m_amx, killerid); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnVehicleSpawn(vehicleid); +int CGameMode::OnVehicleSpawn(cell vehicleid) +{ + CHECK_INIT(); + + int idx; + cell ret = 0; + + if (!amx_FindPublic(&m_amx, "OnVehicleSpawn", &idx)) + { + amx_Push(&m_amx, vehicleid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnVehicleDeath(vehicleid, killerid); +int CGameMode::OnVehicleDeath(cell vehicleid, cell killerid) +{ + CHECK_INIT(); + + int idx; + cell ret = 0; + + if (!amx_FindPublic(&m_amx, "OnVehicleDeath", &idx)) + { + amx_Push(&m_amx, killerid); + amx_Push(&m_amx, vehicleid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerText(playerid, text[]); +int CGameMode::OnPlayerText(cell playerid, unsigned char * szText) +{ + CHECK_INIT(); + + int idx; + cell ret = 1; // DEFAULT TO 1! + int orig_strlen = strlen((char*)szText) + 1; + + if (!amx_FindPublic(&m_amx, "OnPlayerText", &idx)) + { + cell amx_addr, *phys_addr; + amx_PushString(&m_amx, &amx_addr, &phys_addr, (char*)szText, 0, 0); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + amx_GetString((char*)szText, phys_addr, 0, orig_strlen); + amx_Release(&m_amx, amx_addr); + } + + if (ret && pNetGame->GetPlayerPool()->GetSlotState((PLAYERID)playerid)) { + pNetGame->GetPlayerPool()->GetAt((PLAYERID)playerid)->Say(szText, strlen((char*)szText)); + } + + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerCommandText(playerid, cmdtext[]); +int CGameMode::OnPlayerCommandText(cell playerid, unsigned char * szCommandText) +{ + CHECK_INIT(); + + int idx; + cell ret = 0; + //int orig_strlen = strlen((char*)szCommandText); + + if(!pNetGame->GetPlayerPool()->GetSlotState((PLAYERID)playerid)) + return (int)ret; + + if (!amx_FindPublic(&m_amx, "OnPlayerCommandText", &idx)) + { + cell amx_addr, *phys_addr; + amx_PushString(&m_amx, &amx_addr, &phys_addr, (char*)szCommandText, 0, 0); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + amx_Release(&m_amx, amx_addr); + } + + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerInfoChange(playerid); +int CGameMode::OnPlayerInfoChange(cell playerid) +{ + CHECK_INIT(); + + int idx; + cell ret = 0; + + if (!amx_FindPublic(&m_amx, "OnPlayerInfoChange", &idx)) + { + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerRequestClass(playerid, classid); +int CGameMode::OnPlayerRequestClass(cell playerid, cell classid) +{ + CHECK_INIT(); + + int idx; + cell ret = 1; // DEFAULT TO 1! + + if(!pNetGame->GetPlayerPool()->GetSlotState((PLAYERID)playerid)) + return (int)ret; + + if (!amx_FindPublic(&m_amx, "OnPlayerRequestClass", &idx)) + { + amx_Push(&m_amx, classid); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerRequestSpawn(playerid); +int CGameMode::OnPlayerRequestSpawn(cell playerid) +{ + CHECK_INIT(); + + int idx; + cell ret = 1; // DEFAULT TO 1! + + if(!pNetGame->GetPlayerPool()->GetSlotState((PLAYERID)playerid)) + return (int)ret; + + if (!amx_FindPublic(&m_amx, "OnPlayerRequestSpawn", &idx)) + { + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerEnterVehicle(playerid, vehicleid, ispassenger); +int CGameMode::OnPlayerEnterVehicle(cell playerid, cell vehicleid, cell ispassenger) +{ + CHECK_INIT(); + + int idx; + cell ret = 0; + + if(!pNetGame->GetPlayerPool()->GetSlotState((PLAYERID)playerid)) + return (int)ret; + + if (!amx_FindPublic(&m_amx, "OnPlayerEnterVehicle", &idx)) + { + amx_Push(&m_amx, ispassenger); + amx_Push(&m_amx, vehicleid); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerExitVehicle(playerid, vehicleid); +int CGameMode::OnPlayerExitVehicle(cell playerid, cell vehicleid) +{ + CHECK_INIT(); + + int idx; + cell ret = 0; + + if(!pNetGame->GetPlayerPool()->GetSlotState((PLAYERID)playerid)) + return (int)ret; + + if (!amx_FindPublic(&m_amx, "OnPlayerExitVehicle", &idx)) + { + amx_Push(&m_amx, vehicleid); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerStateChange(playerid, newstate, oldstate); +int CGameMode::OnPlayerStateChange(cell playerid, cell newstate, cell oldstate) +{ + CHECK_INIT(); + + int idx; + cell ret = 0; + + if(!pNetGame->GetPlayerPool()->GetSlotState((PLAYERID)playerid)) + return (int)ret; + + if (!amx_FindPublic(&m_amx, "OnPlayerStateChange", &idx)) + { + amx_Push(&m_amx, oldstate); + amx_Push(&m_amx, newstate); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- +// forward OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid); + +int CGameMode::OnPlayerInteriorChange(cell playerid, cell newid, cell oldid) +{ + CHECK_INIT(); + + int idx; + cell ret = 0; + + if(!pNetGame->GetPlayerPool()->GetSlotState((PLAYERID)playerid)) + return (int)ret; + + if (!amx_FindPublic(&m_amx, "OnPlayerInteriorChange", &idx)) + { + amx_Push(&m_amx, oldid); + amx_Push(&m_amx, newid); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerEnterCheckpoint(playerid); +int CGameMode::OnPlayerEnterCheckpoint(cell playerid) +{ + CHECK_INIT(); + + int idx; + cell ret = 0; + + if(!pNetGame->GetPlayerPool()->GetSlotState((PLAYERID)playerid)) + return (int)ret; + + if (!amx_FindPublic(&m_amx, "OnPlayerEnterCheckpoint", &idx)) + { + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerLeaveCheckpoint(playerid); +int CGameMode::OnPlayerLeaveCheckpoint(cell playerid) +{ + CHECK_INIT(); + + int idx; + cell ret = 0; + + if (!amx_FindPublic(&m_amx, "OnPlayerLeaveCheckpoint", &idx)) + { + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerEnterRaceCheckpoint(playerid); +int CGameMode::OnPlayerEnterRaceCheckpoint(cell playerid) +{ + CHECK_INIT(); + + int idx; + cell ret = 0; + + if (!amx_FindPublic(&m_amx, "OnPlayerEnterRaceCheckpoint", &idx)) + { + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerLeaveRaceCheckpoint(playerid); +int CGameMode::OnPlayerLeaveRaceCheckpoint(cell playerid) +{ + CHECK_INIT(); + + int idx; + cell ret = 0; + + if (!amx_FindPublic(&m_amx, "OnPlayerLeaveRaceCheckpoint", &idx)) + { + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerKeyStateChange(playerid,newkeys,oldkeys); +int CGameMode::OnPlayerKeyStateChange(cell playerid, cell newkeys, cell oldkeys) +{ + int idx; + cell ret = 0; + + if (!amx_FindPublic(&m_amx, "OnPlayerKeyStateChange", &idx)) + { + amx_Push(&m_amx, oldkeys); + amx_Push(&m_amx, newkeys); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnRconCommand(cmd[]); +int CGameMode::OnRconCommand(char* szCommand) +{ + CHECK_INIT(); + + int idx; + cell ret = 0; + //int orig_strlen = strlen(szCommand); + + if (!amx_FindPublic(&m_amx, "OnRconCommand", &idx)) + { + cell amx_addr, *phys_addr; + amx_PushString(&m_amx, &amx_addr, &phys_addr, szCommand, 0, 0); + amx_Exec(&m_amx, &ret, idx); + amx_Release(&m_amx, amx_addr); + } + + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnObjectMoved(objectid); +int CGameMode::OnObjectMoved(cell objectid) +{ + CHECK_INIT(); + + int idx; + cell ret = 0; + + if (!amx_FindPublic(&m_amx, "OnObjectMoved", &idx)) + { + amx_Push(&m_amx, objectid); + amx_Exec(&m_amx, &ret, idx); + } + + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerObjectMoved(playerid, objectid); +int CGameMode::OnPlayerObjectMoved(cell playerid, cell objectid) +{ + CHECK_INIT(); + + int idx; + cell ret = 0; + + if (!amx_FindPublic(&m_amx, "OnPlayerObjectMoved", &idx)) + { + amx_Push(&m_amx, objectid); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerPickedUpPickup(playerid, pickupid); +int CGameMode::OnPlayerPickedUpPickup(cell playerid, cell pickupid) +{ + CHECK_INIT(); + + int idx; + cell ret = 0; + + if (!amx_FindPublic(&m_amx, "OnPlayerPickUpPickup", &idx)) + { + amx_Push(&m_amx, pickupid); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerExitedMenu(playerid); +int CGameMode::OnPlayerExitedMenu(cell playerid) +{ + CHECK_INIT(); + + int idx; + cell ret = 0; + + if (!amx_FindPublic(&m_amx, "OnPlayerExitedMenu", &idx)) + { + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerSelectedMenuRow(playerid, row); +int CGameMode::OnPlayerSelectedMenuRow(cell playerid, cell row) +{ + CHECK_INIT(); + + int idx; + cell ret = 0; + + if (!amx_FindPublic(&m_amx, "OnPlayerSelectedMenuRow", &idx)) + { + amx_Push(&m_amx, row); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnVehicleRespray(playerid, vehicleid, color1, color2); +int CGameMode::OnVehicleRespray(cell playerid, cell vehicleid, cell color1, cell color2) +{ + CHECK_INIT(); + int idx; + cell ret = 1; + + if (!amx_FindPublic(&m_amx, "OnVehicleRespray", &idx)) + { + amx_Push(&m_amx, color2); + amx_Push(&m_amx, color1); + amx_Push(&m_amx, vehicleid); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnVehicleMod(playerid, vehicleid, componentid); +int CGameMode::OnVehicleMod(cell playerid, cell vehicleid, cell componentid) +{ + CHECK_INIT(); + int idx; + cell ret = 1; + + if (!amx_FindPublic(&m_amx, "OnVehicleMod", &idx)) + { + amx_Push(&m_amx, componentid); + amx_Push(&m_amx, vehicleid); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnEnterExitModShop(playerid, enterexit, interiorid); +int CGameMode::OnEnterExitModShop(cell playerid, cell enterexit, cell interiorid) +{ + CHECK_INIT(); + int idx; + cell ret = 1; + + if(!amx_FindPublic(&m_amx, "OnEnterExitModShop", &idx)) + { + amx_Push(&m_amx, interiorid); + amx_Push(&m_amx, enterexit); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnVehiclePaintjob(playerid, vehicleid, paintjobid); +int CGameMode::OnVehiclePaintjob(cell playerid, cell vehicleid, cell paintjobid) +{ + CHECK_INIT(); + int idx; + cell ret = 1; + + if (!amx_FindPublic(&m_amx, "OnVehiclePaintjob", &idx)) + { + amx_Push(&m_amx, paintjobid); + amx_Push(&m_amx, vehicleid); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnScriptCash(playerid, amount, increasetype); +int CGameMode::OnScriptCash(cell playerid, cell amount, cell type) +{ + CHECK_INIT(); + int idx; + cell ret = 1; + + if (!amx_FindPublic(&m_amx, "OnScriptCash", &idx)) + { + amx_Push(&m_amx, type); + amx_Push(&m_amx, amount); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnRconLoginAttempt( ip[], password[], success ); +int CGameMode::OnRconLoginAttempt(char *szIP, char *szPassword, cell success) +{ + CHECK_INIT(); + int idx; + cell ret; + + if(!amx_FindPublic(&m_amx, "OnRconLoginAttempt", &idx)) + { + cell amx_addr, amx_addr2, *phys_addr; + amx_Push(&m_amx, success); + amx_PushString(&m_amx, &amx_addr, &phys_addr, szPassword, 0, 0); + amx_PushString(&m_amx, &amx_addr2, &phys_addr, szIP, 0, 0); + amx_Exec(&m_amx, &ret, idx); + amx_Release(&m_amx, amx_addr); + amx_Release(&m_amx, amx_addr2); + } + return 1; +} + +//---------------------------------------------------------------------------------- +// forward OnPlayerUpdate(playerid) + +int CGameMode::OnPlayerUpdate(cell playerid) +{ + CHECK_INIT(); + int idx; + cell ret = 1; + + if(!amx_FindPublic(&m_amx, "OnPlayerUpdate", &idx)) + { + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerStreamIn(playerid, forplayerid); +int CGameMode::OnPlayerStreamIn(cell playerid, cell forplayerid) +{ + CHECK_INIT(); + int idx; + cell ret = 1; + + if(!amx_FindPublic(&m_amx, "OnPlayerStreamIn", &idx)) + { + amx_Push(&m_amx, forplayerid); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerStreamOut(playerid, forplayerid); +int CGameMode::OnPlayerStreamOut(cell playerid, cell forplayerid) +{ + CHECK_INIT(); + int idx; + cell ret = 1; + + if(!amx_FindPublic(&m_amx, "OnPlayerStreamOut", &idx)) + { + amx_Push(&m_amx, forplayerid); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnVehicleStreamIn(vehicleid, forplayerid); +int CGameMode::OnVehicleStreamIn(cell vehicleid, cell forplayerid) +{ + CHECK_INIT(); + int idx; + cell ret = 1; + + if(!amx_FindPublic(&m_amx, "OnVehicleStreamIn", &idx)) + { + amx_Push(&m_amx, forplayerid); + amx_Push(&m_amx, vehicleid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnVehicleStreamOut(vehicleid, forplayerid); +int CGameMode::OnVehicleStreamOut(cell vehicleid, cell forplayerid) +{ + CHECK_INIT(); + int idx; + cell ret = 1; + + if(!amx_FindPublic(&m_amx, "OnVehicleStreamOut", &idx)) + { + amx_Push(&m_amx, forplayerid); + amx_Push(&m_amx, vehicleid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnActorStreamIn(actorid, forplayerid); +int CGameMode::OnActorStreamIn(cell actorid, cell forplayerid) +{ + CHECK_INIT(); + int idx; + cell ret = 1; + + if(!amx_FindPublic(&m_amx, "OnActorStreamIn", &idx)) + { + amx_Push(&m_amx, forplayerid); + amx_Push(&m_amx, actorid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnActorStreamOut(actorid, forplayerid); +int CGameMode::OnActorStreamOut(cell actorid, cell forplayerid) +{ + CHECK_INIT(); + int idx; + cell ret = 1; + + if(!amx_FindPublic(&m_amx, "OnActorStreamOut", &idx)) + { + amx_Push(&m_amx, forplayerid); + amx_Push(&m_amx, actorid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]); +int CGameMode::OnDialogResponse(cell playerid, cell dialogid, cell response, cell listitem, char *szInputText) +{ + CHECK_INIT(); + int idx; + cell ret = 0; + + if(!pNetGame->GetPlayerPool()->GetSlotState((PLAYERID)playerid)) + return (int)ret; + + if(!amx_FindPublic(&m_amx, "OnDialogResponse", &idx)) + { + cell amx_addr, *phys_addr; + amx_PushString(&m_amx, &amx_addr, &phys_addr, szInputText, 0, 0); + amx_Push(&m_amx, listitem); + amx_Push(&m_amx, response); + amx_Push(&m_amx, dialogid); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + amx_Release(&m_amx, amx_addr); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerClickPlayer(playerid, clickedplayerid, source); +int CGameMode::OnPlayerClickPlayer(cell playerid, cell clickedplayerid, cell source) +{ + CHECK_INIT(); + int idx; + cell ret = 0; + + if(!pNetGame->GetPlayerPool()->GetSlotState((PLAYERID)playerid)) + return 0; + + if(!amx_FindPublic(&m_amx, "OnPlayerClickPlayer", &idx)) + { + amx_Push(&m_amx, source); + amx_Push(&m_amx, clickedplayerid); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart); +int CGameMode::OnPlayerTakeDamage(cell playerid, cell issuerid, float amount, cell weaponid, cell bodypart) +{ + int idx; + cell ret = 0; + + if(!amx_FindPublic(&m_amx, "OnPlayerTakeDamage", &idx)) + { + amx_Push(&m_amx, bodypart); + amx_Push(&m_amx, weaponid); + amx_Push(&m_amx, amx_ftoc(amount)); + amx_Push(&m_amx, issuerid); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart); +int CGameMode::OnPlayerGiveDamage(cell playerid, cell damagedid, float amount, cell weaponid, cell bodypart) +{ + int idx; + cell ret = 0; + + if(!amx_FindPublic(&m_amx, "OnPlayerGiveDamage", &idx)) + { + amx_Push(&m_amx, bodypart); + amx_Push(&m_amx, weaponid); + amx_Push(&m_amx, amx_ftoc(amount)); + amx_Push(&m_amx, damagedid); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerGiveDamageActor(playerid, damaged_actorid, Float:amount, weaponid, bodypart); +int CGameMode::OnPlayerGiveDamageActor(cell playerid, cell damaged_actorid, float amount, cell weaponid, cell bodypart) +{ + int idx; + cell ret = 0; + + if(!amx_FindPublic(&m_amx, "OnPlayerGiveDamageActor", &idx)) + { + amx_Push(&m_amx, bodypart); + amx_Push(&m_amx, weaponid); + amx_Push(&m_amx, amx_ftoc(amount)); + amx_Push(&m_amx, damaged_actorid); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnVehicleDamageStatusUpdate(vehicleid, playerid); +int CGameMode::OnVehicleDamageStatusUpdate(cell vehicleid, cell playerid) +{ + CHECK_INIT(); + int idx; + cell ret = 0; + + if(!amx_FindPublic(&m_amx, "OnVehicleDamageStatusUpdate", &idx)) + { + amx_Push(&m_amx, playerid); + amx_Push(&m_amx, vehicleid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat, Float:new_x, Float:new_y, Float:new_z, Float:vel_x, Float:vel_y, Float:vel_z); +int CGameMode::OnUnoccupiedVehicleUpdate(cell vehicleid, cell playerid, cell passenger_seat, int a5, PVECTOR vecNew, PVECTOR vecVel) +{ + CHECK_INIT(); + int idx; + cell ret = 1; + + cell vel_y = amx_ftoc(vecVel->Y); + cell vel_z = amx_ftoc(vecVel->Z); + cell vel_x = amx_ftoc(vecVel->X); + cell new_x = amx_ftoc(vecNew->X); + cell new_y = amx_ftoc(vecNew->Y); + cell new_z = amx_ftoc(vecNew->Z); + + if(!amx_FindPublic(&m_amx, "OnUnoccupiedVehicleUpdate", &idx)) + { + amx_Push(&m_amx, vel_z); + amx_Push(&m_amx, vel_y); + amx_Push(&m_amx, vel_x); + amx_Push(&m_amx, new_z); + amx_Push(&m_amx, new_y); + amx_Push(&m_amx, new_x); + amx_Push(&m_amx, passenger_seat); + amx_Push(&m_amx, playerid); + amx_Push(&m_amx, vehicleid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ); +int CGameMode::OnPlayerClickMap(cell playerid, float fX, float fY, float fZ) +{ + int idx; + cell ret = 0; + + if(!amx_FindPublic(&m_amx, "OnPlayerClickMap", &idx)) + { + amx_Push(&m_amx, amx_ftoc(fZ)); + amx_Push(&m_amx, amx_ftoc(fY)); + amx_Push(&m_amx, amx_ftoc(fX)); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerEditAttachedObject(playerid, response, index, modelid, boneid, +// Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, +// Float:fRotX, Float:fRotY, Float:fRotZ, +// Float:fScaleX, Float:fScaleY, Float:fScaleZ ); +int CGameMode::OnPlayerEditAttachedObject(cell playerid, cell index, cell response, struc_64 *pInfo) +{ + int idx; + cell ret = 0; + + cell offset_x = amx_ftoc(pInfo->vecOffset.X); + cell offset_y = amx_ftoc(pInfo->vecOffset.Y); + cell offset_z = amx_ftoc(pInfo->vecOffset.Z); + cell rot_x = amx_ftoc(pInfo->vecRotation.X); + cell rot_y = amx_ftoc(pInfo->vecRotation.Y); + cell rot_z = amx_ftoc(pInfo->vecRotation.Z); + cell scale_x = amx_ftoc(pInfo->vecScale.X); + cell scale_y = amx_ftoc(pInfo->vecScale.Y); + cell scale_z = amx_ftoc(pInfo->vecScale.Z); + + if(!amx_FindPublic(&m_amx, "OnPlayerEditAttachedObject", &idx)) + { + amx_Push(&m_amx, scale_z); + amx_Push(&m_amx, scale_y); + amx_Push(&m_amx, scale_x); + amx_Push(&m_amx, rot_z); + amx_Push(&m_amx, rot_y); + amx_Push(&m_amx, rot_x); + amx_Push(&m_amx, offset_z); + amx_Push(&m_amx, offset_y); + amx_Push(&m_amx, offset_x); + amx_Push(&m_amx, pInfo->iBoneID); + amx_Push(&m_amx, pInfo->iModelID); + amx_Push(&m_amx, index); + amx_Push(&m_amx, response); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerEditObject( playerid, playerobject, objectid, response, +// Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ ); +int CGameMode::OnPlayerEditObject(cell playerid, cell playerobject, cell objectid, cell response, float fX, float fY, float fZ, float fRotX, float fRotY, float fRotZ) +{ + int idx; + cell ret = 0; + + if(!amx_FindPublic(&m_amx, "OnPlayerEditObject", &idx)) + { + amx_Push(&m_amx, amx_ftoc(fRotZ)); + amx_Push(&m_amx, amx_ftoc(fRotY)); + amx_Push(&m_amx, amx_ftoc(fRotX)); + amx_Push(&m_amx, amx_ftoc(fZ)); + amx_Push(&m_amx, amx_ftoc(fY)); + amx_Push(&m_amx, amx_ftoc(fX)); + amx_Push(&m_amx, response); + amx_Push(&m_amx, objectid); + amx_Push(&m_amx, playerobject); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerSelectObject(playerid, type, objectid, modelid, Float:fX, Float:fY, Float:fZ); +int CGameMode::OnPlayerSelectObject(cell playerid, cell type, cell objectid, cell modelid, float fX, float fY, float fZ) +{ + int idx; + cell ret = 0; + + if(!amx_FindPublic(&m_amx, "OnPlayerSelectObject", &idx)) + { + amx_Push(&m_amx, amx_ftoc(fZ)); + amx_Push(&m_amx, amx_ftoc(fY)); + amx_Push(&m_amx, amx_ftoc(fX)); + amx_Push(&m_amx, modelid); + amx_Push(&m_amx, objectid); + amx_Push(&m_amx, type); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerClickTextDraw(playerid, Text:clickedid); +int CGameMode::OnPlayerClickTextDraw(cell playerid, cell clickedid) +{ + int idx; + cell ret = 0; + + if(!amx_FindPublic(&m_amx, "OnPlayerClickTextDraw", &idx)) + { + amx_Push(&m_amx, clickedid); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid); +int CGameMode::OnPlayerClickPlayerTextDraw(cell playerid, cell playertextid) +{ + int idx; + cell ret = 0; + + if(!amx_FindPublic(&m_amx, "OnPlayerClickPlayerTextDraw", &idx)) + { + amx_Push(&m_amx, playertextid); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +int CGameMode::OnClientCheckResponse(cell a2, cell a3, cell a4, cell a5) +{ + int idx; + cell ret = 0; + + if(!amx_FindPublic(&m_amx, "OnClientCheckResponse", &idx)) + { + amx_Push(&m_amx, a5); + amx_Push(&m_amx, a4); + amx_Push(&m_amx, a3); + amx_Push(&m_amx, a2); + amx_Exec(&m_amx, &ret, idx); + if(ret) return 1; + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ); +int CGameMode::OnPlayerWeaponShot(cell playerid, cell weaponid, cell hittype, cell hitid, PVECTOR vecPos) +{ + int idx; + cell ret = 1; + + cell x = amx_ftoc(vecPos->X); + cell y = amx_ftoc(vecPos->Y); + cell z = amx_ftoc(vecPos->Z); + + if(!amx_FindPublic(&m_amx, "OnPlayerWeaponShot", &idx)) + { + amx_Push(&m_amx, z); + amx_Push(&m_amx, y); + amx_Push(&m_amx, x); + amx_Push(&m_amx, hitid); + amx_Push(&m_amx, hittype); + amx_Push(&m_amx, weaponid); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnIncomingConnection(playerid, ip_address[], port); +int CGameMode::OnIncomingConnection(cell playerid, char *ip_address, cell port) +{ + int idx; + cell ret = 0; + + if (!amx_FindPublic(&m_amx, "OnIncomingConnection", &idx)) + { + cell amx_addr, *phys_addr; + amx_Push(&m_amx, port); + amx_PushString(&m_amx, &amx_addr, &phys_addr, ip_address, 0, 0); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + amx_Release(&m_amx, amx_addr); + } + + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnTrailerUpdate(playerid, vehicleid); +int CGameMode::OnTrailerUpdate(cell playerid, cell vehicleid) +{ + int idx; + cell ret = 1; + + if(!amx_FindPublic(&m_amx, "OnTrailerUpdate", &idx)) + { + amx_Push(&m_amx, vehicleid); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- + +// forward OnVehicleSirenStateChange(playerid, vehicleid, newstate); +int CGameMode::OnVehicleSirenStateChange(cell playerid, cell vehicleid, cell newstate) +{ + int idx; + cell ret = 1; + + if(!amx_FindPublic(&m_amx, "OnVehicleSirenStateChange", &idx)) + { + amx_Push(&m_amx, newstate); + amx_Push(&m_amx, vehicleid); + amx_Push(&m_amx, playerid); + amx_Exec(&m_amx, &ret, idx); + } + return (int)ret; +} + +//---------------------------------------------------------------------------------- diff --git a/server/gamemodes.h b/server/gamemodes.h index ebfbcc2..3d69b8d 100644 --- a/server/gamemodes.h +++ b/server/gamemodes.h @@ -25,6 +25,63 @@ public: int CallPublic(char* szFuncName); + int OnPlayerConnect(cell playerid); + int OnPlayerDisconnect(cell playerid, cell reason); + int OnPlayerSpawn(cell playerid); + int OnPlayerDeath(cell playerid, cell killerid, cell reason); + int OnVehicleSpawn(cell vehicleid); + int OnVehicleDeath(cell vehicleid, cell killerid); + int OnPlayerText(cell playerid, unsigned char * szText); + int OnPlayerCommandText(cell playerid, unsigned char * szCommandText); + int OnPlayerInfoChange(cell playerid); + int OnPlayerRequestClass(cell playerid, cell classid); + int OnPlayerRequestSpawn(cell playerid); + int OnPlayerEnterVehicle(cell playerid, cell vehicleid, cell ispassenger); + int OnPlayerExitVehicle(cell playerid, cell vehicleid); + int OnPlayerStateChange(cell playerid, cell newstate, cell oldstate); + int OnPlayerEnterCheckpoint(cell playerid); + int OnPlayerLeaveCheckpoint(cell playerid); + int OnPlayerEnterRaceCheckpoint(cell playerid); + int OnPlayerLeaveRaceCheckpoint(cell playerid); + int OnRconCommand(char* szCommand); + int OnObjectMoved(cell objectid); + int OnPlayerObjectMoved(cell playerid, cell objectid); + int OnPlayerPickedUpPickup(cell playerid, cell pickupid); + int OnPlayerExitedMenu(cell playerid); + int OnPlayerSelectedMenuRow(cell playerid, cell row); + int OnVehicleRespray(cell playerid, cell vehicleid, cell color1, cell color2); + int OnVehicleMod(cell playerid, cell vehicleid, cell componentid); + int OnEnterExitModShop(cell playerid, cell enterexit, cell interiorid); + int OnVehiclePaintjob(cell playerid, cell vehicleid, cell paintjobid); + int OnPlayerInteriorChange(cell playerid, cell newid, cell oldid); + int OnPlayerKeyStateChange(cell playerid, cell newkeys, cell oldkeys); + int OnScriptCash(cell playerid, cell amount, cell type); + int OnRconLoginAttempt(char *szIP, char *szPassword, cell success); + int OnPlayerUpdate(cell playerid); + int OnPlayerStreamIn(cell playerid, cell forplayerid); + int OnPlayerStreamOut(cell playerid, cell forplayerid); + int OnVehicleStreamIn(cell vehicleid, cell forplayerid); + int OnVehicleStreamOut(cell vehicleid, cell forplayerid); + int OnActorStreamIn(cell actorid, cell forplayerid); + int OnActorStreamOut(cell actorid, cell forplayerid); + int OnDialogResponse(cell playerid, cell dialogid, cell response, cell listitem, char *szInputText); + int OnPlayerClickPlayer(cell playerid, cell clickedplayerid, cell source); + int OnPlayerTakeDamage(cell playerid, cell issuerid, float amount, cell weaponid, cell bodypart); + int OnPlayerGiveDamage(cell playerid, cell damagedid, float amount, cell weaponid, cell bodypart); + int OnPlayerGiveDamageActor(cell playerid, cell damaged_actorid, float amount, cell weaponid, cell bodypart); + int OnVehicleDamageStatusUpdate(cell vehicleid, cell playerid); + int OnUnoccupiedVehicleUpdate(cell vehicleid, cell playerid, cell passenger_seat, int a5, PVECTOR vecNew, PVECTOR vecVel); + int OnPlayerClickMap(cell playerid, float fX, float fY, float fZ); + int OnPlayerEditAttachedObject(cell playerid, cell index, cell response, struc_64 *pInfo); + int OnPlayerEditObject(cell playerid, cell playerobject, cell objectid, cell response, float fX, float fY, float fZ, float fRotX, float fRotY, float fRotZ); + int OnPlayerSelectObject(cell playerid, cell type, cell objectid, cell modelid, float fX, float fY, float fZ); + int OnPlayerClickTextDraw(cell playerid, cell clickedid); + int OnPlayerClickPlayerTextDraw(cell playerid, cell playertextid); + int OnClientCheckResponse(cell a2, cell a3, cell a4, cell a5); // unused + int OnPlayerWeaponShot(cell playerid, cell weaponid, cell hittype, cell hitid, PVECTOR vecPos); + int OnIncomingConnection(cell playerid, char *ip_address, cell port); + int OnTrailerUpdate(cell playerid, cell vehicleid); + int OnVehicleSirenStateChange(cell playerid, cell vehicleid, cell newstate); }; //---------------------------------------------------------------------------------- diff --git a/server/netgame.h b/server/netgame.h index 5634f22..36d947a 100644 --- a/server/netgame.h +++ b/server/netgame.h @@ -71,6 +71,7 @@ public: void Init(BOOL bFirst); void ShutdownForGameModeRestart(); + CPlayerPool * GetPlayerPool() { return m_pPlayerPool; }; RakServerInterface * GetRakServer() { return m_pRak; }; void LoadAllFilterscripts(); diff --git a/server/player.cpp b/server/player.cpp index dd84292..11056fe 100644 --- a/server/player.cpp +++ b/server/player.cpp @@ -1,3 +1,12 @@ #include "main.h" +//---------------------------------------------------- + +void CPlayer::Say(unsigned char * szText, BYTE byteTextLen) +{ + // TODO: CPlayer::Say +} + +//---------------------------------------------------- + diff --git a/server/player.h b/server/player.h index 11be3ca..745fb1a 100644 --- a/server/player.h +++ b/server/player.h @@ -9,6 +9,8 @@ private: public: + void Say(unsigned char * szText, BYTE byteTextLength); + }; #endif diff --git a/server/playerpool.h b/server/playerpool.h index 8524a07..a40c3b0 100644 --- a/server/playerpool.h +++ b/server/playerpool.h @@ -42,6 +42,18 @@ public: BOOL Delete(PLAYERID playerId, BYTE byteReason); + // Retrieve a player + CPlayer* GetAt(PLAYERID playerId) { + if (playerId >= MAX_PLAYERS) { return NULL; } + return m_pPlayers[playerId]; + }; + + // Find out if the slot is inuse. + BOOL GetSlotState(PLAYERID playerId) { + if(playerId >= MAX_PLAYERS) { return FALSE; } + return m_bPlayerSlotState[playerId]; + }; + void ResetPlayerScoresAndMoney() { memset(&m_iPlayerScore[0],0,sizeof(int) * MAX_PLAYERS); memset(&m_iPlayerMoney[0],0,sizeof(int) * MAX_PLAYERS);