08.05.2018, 12:20
Can someone given me a tutorial for " If there someone wanna rob somthing given him Chance.. Sometimes ROBBING FAILED & sometimes Robbing Completed.
How to I can do it?
How to I can do it?
new chance = random(100) //Random number (from 0 to 99) if(chance <= 14) //15% chance of success { ... //Do your actions here upon success } else { ... //Do your actions here upon failure }
CMD:breakcuff(playerid, params[])
{
if(PoliceTeam(GetPlayerSkin(playerid))) return SendClientMessage(playerid, -1, "{ff0000}Error: {Ffffff}Only Civilian can use this comamnd.");
new chance = random(100)
if(chance <= 65)
{
SendClientMessage(playerid, -1, "rtr");
}
if(BeginArrested[playerid] == 1 && Civilian(GetPlayerSkin(playerid)))
{
KillTimer(BeginArrestedTime[playerid]);
SendClientMessage(playerid, -1, "{FF7000}YOU HAVE BEEN ESCAPED FROM ARRESTED!!! RUN RUN !!!!");
SetPlayerWantedLevel(playerid, 3);
SetPlayerColor(playerid, YELLOW);
GameTextForPlayer(playerid, "~Y~ESCAPED FROM ~G~ARRESTED ~P~ RUN BABY!!!", 7000, 5);
SetPlayerSpecialAction(playerid,SPECIAL_ACTION_NONE);
BeginArrested[playerid] = 0;
}else{
SendClientMessage(playerid, -1, "{FF0000}Error: {FFFFFF}You can use this command only while be cuffed or arrested.");
}
return 1;
}
error 001: expected token: ";", but found "if"
CMD:breakcuff(playerid, params[])
{
if(PoliceTeam(GetPlayerSkin(playerid))) return SendClientMessage(playerid, -1, "{ff0000}Error: {Ffffff}Only Civilian can use this comamnd.");
//new chance = random(100) <- here is the error
new chance = random(100);
if(chance <= 65)
{
SendClientMessage(playerid, -1, "rtr");
}
if(BeginArrested[playerid] == 1 && Civilian(GetPlayerSkin(playerid)))
{
KillTimer(BeginArrestedTime[playerid]);
SendClientMessage(playerid, -1, "{FF7000}YOU HAVE BEEN ESCAPED FROM ARRESTED!!! RUN RUN !!!!");
SetPlayerWantedLevel(playerid, 3);
SetPlayerColor(playerid, YELLOW);
GameTextForPlayer(playerid, "~Y~ESCAPED FROM ~G~ARRESTED ~P~ RUN BABY!!!", 7000, 5);
SetPlayerSpecialAction(playerid,SPECIAL_ACTION_NONE);
BeginArrested[playerid] = 0;
}else{
SendClientMessage(playerid, -1, "{FF0000}Error: {FFFFFF}You can use this command only while be cuffed or arrested.");
}
return 1;
}
forward GetOuts1(playerid);
public GetOuts1(playerid)
{
//here code
}
forward GetOuts2(playerid);
public GetOuts2(playerid)
{
//here code
}
CMD:getouts(playerid, params[])
{
new chance=random(4);
if(chance==1)
{
//here code
SetTimerEx("GetOuts1", 2300, 0, "i", playerid);
}
else
{
//here code
SetTimerEx("GetOuts2", 2300, 0, "i", playerid);
}
return 1;
}
switch(random(100))
{
case 0..50:
{
// 50% chance
}
case 51..80:
{
// 30% chance
}
case 81..100:
{
// 20% chance
}
}
PHP код:
|
LoL, he want random chance like 1-100 any he didnot said that he want 20% chance 10%chance lol please read the post and then reply it ok, dont reply for increasing your posts, because if you want to increase your posts you must really know scripting, which you can learn from hwe https://sampwiki.blast.hk/
if you want help then you can go for scripting help |
CMD:breakcuff(playerid)
{
if(PoliceTeam(GetPlayerSkin(playerid))) return SendClientMessage(playerid, -1, "{ff0000}Error: {Ffffff}Only Civilian can use this comamnd.");
if(BeginArrested[playerid] == 1 && Civilian(GetPlayerSkin(playerid)))
{
switch(random(100))
{
case 0..35: // 35% chance
{
KillTimer(BeginArrestedTime[playerid]);
//SendClientMessage(playerid, -1, "{FF7000}YOU HAVE BEEN ESCAPED FROM ARRESTED!!! RUN RUN !!!!");
// "-1" is actually the color. You should consider using it as shown below:
SendClientMessage(playerid, 0xFF7000FF, "YOU HAVE ESCAPED THE ARREST!!! RUN RUN !!!!");
SetPlayerWantedLevel(playerid, 3); // It's better to automatically set player color based on wanted level.
SetPlayerColor(playerid, YELLOW); // ^^ (READ EXAMPLE 1 BELOW)
GameTextForPlayer(playerid, "~Y~ESCAPED FROM ~G~ARREST ~P~ RUN BABY!!!", 7000, 5);
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
BeginArrested[playerid] = 0;
}
case 36..100: SendClientMessage(playerid, -1, "Failed to break cuffs.");
}
}
else
SendClientMessage(playerid, -1, "{FF0000}Error: {FFFFFF}You can use this command only while being cuffed or arrested.");
return 1;
}
// EXAMPLE 1: (Create a 1 or 2 second timer per player, or better - Hook SetPlayerWantedLevel function. Tutorial: https://sampforum.blast.hk/showthread.ph...4.35138979
new wantedl = GetPlayerWantedLevel(playerid);
if(wantedl == 0) SetPlayerColor(playerid, COLOR_WHITE);
else if(wantedl == 1) SetPlayerColor(playerid, COLOR_YELLOW);
else if(wantedl >= 2 && wantedl < 5) SetPlayerColor(playerid, COLOR_ORANGE);
else if(wantedl >= 5) SetPlayerColor(playerid, COLOR_RED);
// And for sake of God, change the way you're checking for player team. It's extremely bad. I gave you an example in your previous threads.
case 36..100: SendClientMessage(playerid, -1, "Failed to break cuffs.");
case 36..100: GameTextForPlayer(playerid, "~B~HANDCUFFS ~R~FAILED TO BREAK", 7000, 5);
error 040: duplicate "case" label (value 36)