Senior Member
Join Date: Oct 2008
Location: /var/www/index.html
|
02-05-2021
, 07:47
Re: [L4D & L4D2] Tank Pass v2.5 [02 Sep 2020]
|
#13
|
Here I made some modification, with native support, let other plugins use Tank Pass!
Fix Server with points_system plugins and more 4 infected player:
When 5th...nth player bought a tank, server spawn with wrong player, Tank Pass plugins transfer Tank to bought player
Native:
PHP Code:
/** * Change player Tank to another target player * * @param num1 target tank player. * @param num2 target client to play as tank. */ native void TS_TankPass(int iClientOld, int iClientNew);
points system need to modified:
PHP Code:
#include <l4d_tank_pass> ... bool ClientBoughtTank[MAXPLAYERS] = { false, ... }; ... void hookGameEvents() { ... HookEvent("player_spawn", Event_Spawn); //new return; } ... public Action Event_Spawn(Handle hEvent, const char[] sEventName, bool bDontBroadcast) { int client = GetClientOfUserId(GetEventInt(hEvent, "userid"));
if (client == 0) return;
if (IsFakeClient(client)) return;
if (GetEntProp(client, Prop_Send, "m_zombieClass") == 8) // TANK { if (ClientBoughtTank[client]) { ClientBoughtTank[client] = false; // state reset before swap happen, prevent double trigger PrintToChat(client, "\x04[Lewd4Dead] \x01You bought the \x05TANK\x01! Crush them!"); } else { for (int i = 1; i <= MaxClients; i++) { if (ClientBoughtTank[i]) { ClientBoughtTank[i] = false; // state reset before swap happen, prevent double trigger
if (GetEntProp(i, Prop_Send, "m_zombieClass") == 8) // block player already tank, give to other player { PrintToChatAll("\x04[Lewd4Dead] \x05%N \x01bought a \x03Tank \x01and server give it to \x05%N", i, client); return; }
PrintToChat(client, "\x04[Lewd4Dead] \x01Transfering this Tank to \x05%N", i); PrintToChat(i, "\x04[Lewd4Dead] \x01You received a Tank from \x05%N", client);
TS_TankPass(client, i);
break; } } } } return; } ... public MenuHandler_ConfirmI(Handle:menu, MenuAction:action, param1, param2) { switch(action) { case MenuAction_End: { CloseHandle(menu); } case MenuAction_Cancel: { strcopy(PlayerData[param1][sItemName], 64, PlayerData[param1][sBought]); PlayerData[param1][iItemCost] = PlayerData[param1][iBoughtCost]; } case MenuAction_Select: { decl String:choice[40]; GetMenuItem(menu, param2, choice, sizeof(choice)); if (StrEqual(choice, "no", false)) { BuildBuyMenu(param1); strcopy(PlayerData[param1][sItemName], 64, PlayerData[param1][sBought]); PlayerData[param1][iItemCost] = PlayerData[param1][iBoughtCost]; } else if (StrEqual(choice, "yes", false)) { if (!HasEnoughPoints(param1, PlayerData[param1][iItemCost])) return; if (!IsPlayerAlive(param1)) { PrintToChat(param1, "\x04[Lewd4Dead] \x01You need in \x03Spawn Ready \x01before can make a purchase."); return; }
if (StrEqual(PlayerData[param1][sItemName], "suicide", false)) { performSuicide(param1, PlayerData[param1][iItemCost]); return; } else if (StrEqual(PlayerData[param1][sItemName], "z_spawn mob", false)) { CounterData[iUCommonLeft] += GetConVarInt(FindConVar("z_common_limit")); } else if (StrEqual(PlayerData[param1][sItemName], "z_spawn tank auto", false)) { if (CounterData[iTanksSpawned] == GetConVarInt(PluginSettings[hTankLimit])) { PrintToChat(param1, "%T", "Tank Limit", LANG_SERVER); return; }
ClientBoughtTank[param1] = true; // tag player bought a tank CounterData[iTanksSpawned]++; } else if (StrEqual(PlayerData[param1][sItemName], "z_spawn witch auto", false) || StrEqual(PlayerData[param1][sItemName], "z_spawn witch_bride auto", false)) { if (CounterData[iWitchesSpawned] == GetConVarInt(PluginSettings[hWitchLimit])) { PrintToChat(param1, "%T", "Witch Limit", LANG_SERVER); return; } CounterData[iWitchesSpawned]++; } else if (StrContains(PlayerData[param1][sItemName], "z_spawn", false) != -1 && StrContains(PlayerData[param1][sItemName], "mob", false) == -1) { if (IsPlayerAlive(param1) || IsPlayerGhost(param1)) { return; } new bool:resetGhost[MaxClients+1], bool:resetAlive[MaxClients+1], bool:resetLifeState[MaxClients+1]; for (new i=1;i<=MaxClients;i++) { if (i == param1 || !IsClientInGame(i) || GetClientTeam(i) != 3 || IsFakeClient(i)) { continue; }
if (IsPlayerGhost(i)) { resetGhost[i] = true; resetAlive[i] = true; SetPlayerGhost(i, false); SetPlayerAlive(i, true); } else if (!IsPlayerAlive(i)) { resetLifeState[i] = true; SetPlayerLifeState(i, false); } }
execClientCommand(param1, PlayerData[param1][sItemName]);
new maxretry = GetConVarInt(PluginSettings[hSpawnAttempts]); for (new i;i<maxretry;i++) { if (!IsPlayerAlive(param1)) { execClientCommand(param1, PlayerData[param1][sItemName]); } }
if (IsPlayerAlive(param1)) { strcopy(PlayerData[param1][sBought], 64, PlayerData[param1][sItemName]); PlayerData[param1][iBoughtCost] = PlayerData[param1][iItemCost]; removePoints(param1, PlayerData[param1][iItemCost]); } else { PrintToChat(param1, "%s %T", MSGTAG, "Spawn Failed", param1); }
for (new i=1;i<=MaxClients;i++) { if (resetGhost[i]) SetPlayerGhost(i, true); if (resetAlive[i]) SetPlayerAlive(i, false); if (resetLifeState[i]) SetPlayerLifeState(i, true); } return; } strcopy(PlayerData[param1][sBought], 64, PlayerData[param1][sItemName]); PlayerData[param1][iBoughtCost] = PlayerData[param1][iItemCost]; removePoints(param1, PlayerData[param1][iItemCost]); execClientCommand(param1, PlayerData[param1][sItemName]); } } } }
__________________
Last edited by ilham92-cc-sakura; 02-05-2021 at 07:48.
|
|