Actor Robbery System - Problem -
BrainDamaged - 26.01.2018
Hi, I am trying to switch (
https://sampforum.blast.hk/showthread.php?pid=3945923#pid3945923) to (
https://sampforum.blast.hk/showthread.php?tid=573762) mode to change the robbery system, but my robberies always fail because of a reason I do not know. Can you help me ?
Please help me
Note: Sorry my bad english
Re: Actor Robbery System - Problem -
Fratello - 26.01.2018
Mind providing the code here?
You can follow this code. It's (yet) another classic version of the fail system you can follow if you want to. Just a reminder, a random number for a computer is: 0 1 1 0 (pseudo random). You can look for pseudo random patches or fixes. I've seen one recently.
Код:
new _robbery = random(1);
switch(_robbery)
{
case 0:
{
// Robbed
}
case 1:
{
// Failed
}
}
Re: Actor Robbery System - Problem -
BrainDamaged - 27.01.2018
I've fixed the problem, but I'm having trouble with the money.
Код:
CreateActorRobbery(72, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, MIN_MONEY_ROB, MAX_MONEY_ROB);
Код:
public OnPlayerFinishRobbery(playerid, actorid, robbedmoney, type)
{
new string[128];
switch(type)
{
case TYPE_SUCCESS:
{
format(string, sizeof(string), "[ROBBERY SUCCESS]: You have manage to steal $%i from actorid: %i", robbedmoney, actorid);
SendClientMessage(playerid, -1, string);
//giveXP(playerid, 5);
//giveScore(playerid, 2);
GivePlayerMoney(playerid, robbedmoney);
format(string, sizeof(string), "~w~You stole~n~~g~$%i", robbedmoney);
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);
}
}
giveWanted(playerid, 6);
return 1;
}
Код:
#define MIN_MONEY_ROB 500
#define MAX_MONEY_ROB 10000
How can I pay between MIN_MONEY_ROB and MAX_MONEY_ROB ?
Sorry my bad english
Re: Actor Robbery System - Problem -
wallee - 27.01.2018
Try this:
new robbedmoney = random(MAX_MONEY_ROB) + MIN_MONEY_ROB;
GivePlayerMoney(playerid, robbedmoney);
Re: Actor Robbery System - Problem -
BrainDamaged - 27.01.2018
It gives an error despite my application
Re: Actor Robbery System - Problem -
OmerKhan - 27.01.2018
It's only a warning I guess
Re: Actor Robbery System - Problem -
BrainDamaged - 27.01.2018
If we get 10 meters away from the actor, how can I cancel the robbery?
Код:
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;
}