CMD:activate(playerid) { new Float:x,Float:y,Float:z; // Get Player Coordinate { if(pInfo[playerid][HasCherryPerk] == 1) { if(maptime <= 120) // If Map Time is less than 120 seconds (2 Minutes) { GetPlayerPos(playerid,Float:x,Float:y,Float:z); // Get Player Position if(team[playerid] == TEAM_HUMAN)// if team is Human { fucktimer[playerid] = SetTimerEx("GetCherried", 3000, false, "i", playerid); CageHuman = CreateObject(971, Float:x+4.0,Float:y+4.0,Float:z+0.0, 0.0, 0.0, 0.0); CageHuman1 = CreateObject(971, Float:x+4.0,Float:y-4.0,Float:z-0.0, 0.0, 0.0, 0.0); CageHuman2 = CreateObject(971, Float:x-1.0,Float:y+0.0,Float:z-0.0, 0.0, 0.0, 90.0); CageHuman3 = CreateObject(971, Float:x+8.0,Float:y+0.0,Float:z-0.0, 0.0, 0.0, 90.0); CageHuman4 = CreateObject(971, Float:x+4.0,Float:y+0.0,Float:z+3.0, 90.0, 0.0, 0.0); uselesstimer[playerid] = SetTimerEx("HideObject971", 9000, false, "i", playerid); } } } } return 1; } forward GetCherried(playerid); public GetCherried(playerid) { new Float:x,Float:y,Float:z,Float:Angle; GetPlayerPos(playerid,Float:x,Float:y,Float:z); GetPlayerFacingAngle(playerid,Float:Angle); foreach(Player,i) { if(team[i] == TEAM_ZOMBIE) { if(GetDistanceBetweenPlayers(playerid,i) < 15.0) { GetClosestPlayer(i); GetPlayerFacingAngle(i,Float:Angle); GetPlayerVelocity(i,Float:x,Float:y,Float:z); SetPlayerVelocity(i,Float:x+0.3,Float:y+0.3,Float:z+0.2); SetPlayerFacingAngle(i,Float:Angle); } } } return 1; } forward HideObject971(playerid); public HideObject971(playerid) { DestroyObject(CageHuman); DestroyObject(CageHuman1); DestroyObject(CageHuman2); DestroyObject(CageHuman3); DestroyObject(CageHuman4); KillTimer(fucktimer[playerid]); return 1; }
Where is created the variable CageHuman? If is global you need to destroy the previos creation of the object before you create . In command replace
If (IsValidObject(CageHuman)) DestroyObject (CageHuman); // do it for all before create CageHuman = CreateObject(971, Float+4.0,Float:y+4.0,Float:z+0.0, 0.0, 0.0, 0.0); |
new CherryCount[MAX_PLAYERS];
new CageHuman[MAX_PLAYERS][5] = {INVALID_OBJECT_ID, ...};
CMD:activate(playerid)
{
if(pInfo[playerid][HasCherryPerk] == 1)
{
if(maptime <= 120) // If Map Time is less than 120 seconds (2 Minutes)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, Float:x, Float:y, Float:z); // Get Player Position
if(team[playerid] == TEAM_HUMAN)// if team is Human
{
if(CherryCount[playerid]++ != 0) return SendClientMessage(playerid, -1, "You have already enabled this perk.");
SetTimerEx("GetCherried", 3000, false, "i", playerid);
CageHuman[playerid][0] = CreateObject(971, Float:x + 4.0, Float:y + 4.0, Float:z, 0.0, 0.0, 0.0);
CageHuman[playerid][1] = CreateObject(971, Float:x + 4.0, Float:y - 4.0, Float:z, 0.0, 0.0, 0.0);
CageHuman[playerid][2] = CreateObject(971, Float:x - 1.0, Float:y, Float:z, 0.0, 0.0, 90.0);
CageHuman[playerid][3] = CreateObject(971, Float:x + 8.0, Float:y, Float:z, 0.0, 0.0, 90.0);
CageHuman[playerid][4] = CreateObject(971, Float:x + 4.0, Float:y, Float:z + 3.0, 90.0, 0.0, 0.0);
}
// else SendClientMessage(playerid, -1, "Only Humans can use this perk.");
}
// else SendClientMessage(playerid, -1, "Map Time is more than 120 seconds.");
}
// else SendClientMessage(playerid, -1, "You don't have the Cherry perk.");
return 1;
}
forward GetCherried(playerid);
public GetCherried(playerid)
{
new Float:x, Float:y, Float:z;
foreach(new i : Player)
{
if(i == playerid || team[i] != TEAM_ZOMBIE) continue;
if(GetDistanceBetweenPlayers(playerid, i) < 15.0)
{
GetPlayerVelocity(i, Float:x, Float:y, Float:z);
SetPlayerVelocity(i, Float:x + 0.3, Float:y + 0.3, Float:z + 0.2);
}
}
if(!IsPlayerConnected(playerid) || ++CherryCount[playerid] > 3)
{
for(new j = 0; j < sizeof(CageHuman[]); j++)
{
DestroyObject(CageHuman[playerid][j]);
CageHuman[playerid][j] = INVALID_OBJECT_ID;
}
CherryCount[playerid] = 0;
return 1;
}
else SetTimerEx("GetCherried", 3000, false, "i", playerid);
return 1;
}
I just spent ages writing a massive post and it said my token had expired because I left the page open too long... so I'm just going to spit some code at you and let you figure it out.
PHP код:
|
if(!IsPlayerConnected(playerid) || ++CherryCount[playerid] > 3)