SA-MP Forums Archive
Chance - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Chance (/showthread.php?tid=501577)



Chance - Mriss - 19.03.2014

Hey, How do I make it only a "chance" for something to work like my command

pawn Код:
CMD:breakcuffs(playerid, params[])
{
    new string[64];

    if(pCuffed[tid] == 1)
    {
        pCuffed[tid] = 0; // set var

        SendClientMessage(playerid, -1, "You have broken your cuffs.");

        RemovePlayerAttachedObject(playerid, 7); // remove their attached object
        SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
    }
    else SendClientMessage(playerid, -1, "You aren't cuffed!");
    return 1;
}
Could someone make it a 50/50 Chance for it to work?


Re: Chance - AssMunchingFool - 19.03.2014

use random()

pawn Код:
new randomChance = random(2); // 50/50% chance
if(randomChance==0)
{
  //you broke ur cuffs
}
else if(randomChance==1)
{
   // you failed to break out
}



Re: Chance - Mriss - 19.03.2014

So, This is what I did.

pawn Код:
new randomChance = random(2); // 50/50% chance
if(randomChance==0)
{
    SendClientMessage(playerid, -1, "You have broken your cuffs.");
    RemovePlayerAttachedObject(playerid, 7); // remove their attached object
    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
}
else if(randomChance==1)
{
   SendClientMessage(playerid, -1, "You have failed to break your cuffs.");
}
Where do I put it?


Re: Chance - Mriss - 19.03.2014

nvm this is my cmd:

pawn Код:
CMD:breakcuffs(playerid, params[])
{
   
    if(pCuffed[playerid] == 1)
    {
    new randomChance = random(2); // 50/50% chance
    if(randomChance==0)
    {
        pCuffed[playerid] = 0;
        SendClientMessage(playerid, -1, "You have broken your cuffs.");
        RemovePlayerAttachedObject(playerid, 7); // remove their attached object
        SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
    }
    else if(randomChance==1)
    {
   SendClientMessage(playerid, -1, "You have failed to break your cuffs.");
    }
    }
    else SendClientMessage(playerid, -1, "You aren't cuffed!");
    return 1;
}
WIll it work?, It compiles All G'


Re: Chance - AssMunchingFool - 19.03.2014

should work