Код:
public RunActorAnimationSequence(playerid, actorid, animation_pattern)
{
switch(animation_pattern)
{
case 0:
{
ClearActorAnimations(actorid);
ApplyActorAnimation(actorid, "SHOP", "SHP_Rob_HandsUp", 4.1, 0, 1, 1, 1, 0);
SetTimerEx("RunActorAnimationSequence", 1000 * ROBBERY_WAIT_TIME, false, "iii", playerid, actorid, 1);
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(!IsPlayerConnected(i)) { continue; }
PlayerPlaySound(i, 3401, x, y, z);
}
}
case 1:
{
if(!IsPlayerInRangeOfPoint(playerid, 10.0, robbery_data[actorid][actor_x], robbery_data[actorid][actor_y], robbery_data[actorid][actor_z]))
{
ClearActorAnimations(actorid);
ApplyActorAnimation(actorid, "SHOP", "SHP_Rob_GiveCash", 4.1, 0, 1, 1, 1, 0);
SetTimerEx("RunActorAnimationSequence", 1000 * ROBBERY_WAIT_TIME, false, "iii", playerid, actorid, 2);
}
else
{
OnPlayerFinishRobbery(playerid, actorid, 0, TYPE_UNFINISHED);
}
}
case 2:
{
ClearActorAnimations(actorid);
ApplyActorAnimation(actorid, "PED", "DUCK_cower", 4.1, 1, 1, 1, 1, 1);
SetTimerEx("RunActorAnimationSequence", 1000 * 60 * ROBBERY_WAIT_TIME, false, "iii", playerid, actorid, 3);
new
robberyChance = random(100);
if(robberyChance > 40)
{
OnPlayerFinishRobbery(playerid, actorid, (random(robbery_data[actorid][money_max] - robbery_data[actorid][money_min]) + robbery_data[actorid][money_min]), TYPE_SUCCESS);
}
else OnPlayerFinishRobbery(playerid, actorid, 0, TYPE_FAILED);
}
case 3:
{
ClearActorAnimations(actorid);
PlayerPlaySound(playerid, 0, 0.0, 0.0, 0.0);
}
}
return 1;
}
public OnPlayerStartRobbery(playerid, actorid, robbed_recently)
{
new string[128];
if(robbed_recently)
{
format(string, sizeof(string), "ActorID: %i -> has been robbed recently, please try again later!", actorid);
SendClientMessage(playerid, -1, string);
return 0;
}
else
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "Player %s(%i) has begun robbing actorid: %i", name, playerid, actorid);
SendClientMessage(playerid, -1, string);
}
return 1;
}
public OnPlayerFinishRobbery(playerid, actorid, robbedmoney, type)
{
new string[128];
switch(type)
{
case TYPE_SUCCESS:
{
new robbedmoneyy = random(MAX_MONEY_ROB) + MIN_MONEY_ROB;
giveMoney(playerid, robbedmoneyy);
giveXP(playerid, 5);
giveScore(playerid, 2);
format(string, sizeof(string), "[ROBBERY SUCCESS]: You have manage to steal $%i from actorid: %i", robbedmoneyy, actorid);
SendClientMessage(playerid, -1, string);
//GivePlayerMoney(playerid, MIN_MONEY_ROB-MAX_MONEY_ROB);
format(string, sizeof(string), "~w~You stole~n~~g~$%i", robbedmoneyy);
GameTextForPlayer(playerid, string, 6000, 1);
}
case TYPE_FAILED:
{
SendClientMessage(playerid, -1, "[ROBBERY FAILED]: Cashier refused to give money!");
GameTextForPlayer(playerid, "~r~Robbery Failed", 6000, 1);
}
case TYPE_UNFINISHED:
{
SendClientMessage(playerid, -1, "[ROBBERY FAILED]: You have gone too far away from the actor, he managed to call 911! RUN!");
GameTextForPlayer(playerid, "~r~Robbery Failed", 6000, 1);
}
}
giveWanted(playerid, 6);
return 1;
}