22.12.2011, 17:25
Dont get whats wrong! So, basicaly, you shoot player with Country Rifle and player gets stunned! Stuning player works perfect, but i have problems with command -> /arrest <stuned-playerid>! Please take a look and help if you know whats the problem!
Even though if the player is stunned, its returns an error -> "That player is not stunned!"
pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid) //Works
{
if(Enforcer[playerid] == 1)
{
if(GetPlayerWeapon(playerid) == 33)
{
StunPlayer(damagedid);
SetTimer("StunTime",7000,false);
}
return 1;
}
return 0;
}
public StunTime() //Works
{
for(new i=0; i < MAX_PLAYERS; i++)
{
if(Stuned[i] == 1)
{
TogglePlayerControllable(i,1);
Stuned[i] = 0;
ClearAnimations(i);
return 1;
}
}
return 1;
}
COMMAND:arrest(playerid, params[]) //Dont works
{
new stunedid;
if (Enforcer[playerid] == 1)
{
if (!sscanf(params, "u", stunedid))
{
if (Stuned[stunedid] == 1) //This is the problem
{
SetPlayerScore(stunedid,GetPlayerScore(stunedid)-10);
GivePlayerMoney(stunedid,-10000);
new rand = random(sizeof(RandomCrimSpawns));
SetPlayerPos(stunedid, RandomCrimSpawns[rand][0], RandomCrimSpawns[rand][1], RandomCrimSpawns[rand][2]);
SetPlayerFacingAngle(stunedid, RandomCrimSpawns[rand][3]);
SetCameraBehindPlayer(stunedid);
SendClientMessage(stunedid,GCOLOR_GREY,"* You have been arrested! You lost 10000$ and 10 Score");
SetPlayerScore(playerid,GetPlayerScore(playerid)+10);
GivePlayerMoney(playerid,10000);
SendClientMessage(stunedid,GCOLOR_GREY,"* You arrested Criminal and received 10000$ and 10 Score");
}
else SendClientMessage(playerid, GCOLOR_RED, "ERROR: That player is not stunned!");
}
else SendClientMessage(playerid, GCOLOR_RED, "Usage: /arrest <stuned-playerid>");
}
else SendClientMessage(playerid, GCOLOR_RED, "ERROR: Only Enforcers can use this command!");
return 1;
}
stock StunPlayer(playerid)
{
TogglePlayerControllable(playerid,0);
GameTextForPlayer(playerid,"~r~STUNNED!",7000,3);
Stuned[playerid] = 1;
ApplyAnimation(playerid, "ped", "cower", 3.0, 1, 0, 0, 0, 0);
return 1;
}