Chance
#1

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?
Reply
#2

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
}
Reply
#3

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?
Reply
#4

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'
Reply
#5

should work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)