SA-MP Forums Archive
Making commands to randomly work? - 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: Making commands to randomly work? (/showthread.php?tid=388165)



Making commands to randomly work? - davve95 - 27.10.2012

Hi!

I have figure out very much things with sucess by my own.

But I can't figure out how to make example a robbery system like: "You can't rob" ...
I don't need the robbery system just that I talk about.


Re: Making commands to randomly work? - NewerthRoleplay - 27.10.2012

Im guessing you mean something using this: https://sampwiki.blast.hk/wiki/Random


Re: Making commands to randomly work? - davve95 - 27.10.2012

Quote:
Originally Posted by NewerthRoleplay
View Post
Im guessing you mean something using this: https://sampwiki.blast.hk/wiki/Random
Yes I think it will work! Thanks alot!.


Re: Making commands to randomly work? - ReneG - 27.10.2012

example
pawn Code:
CMD:command(playerid, params[])
{
    switch(random(2))
    {
        case 1:
            SendClientMessage(playerid, -1, "Success!");
           
        default:
            SendClientMessage(playerid, -1, "Failed!");
    }
    return 1;
}
random(2) - %50 percent chance of succeeding
random(3) - %33 percent chance of succeeding
random(4) - %25 percent chance of succeeding
random(5) - %20 percent chance of succeeding

etc.

Heres a page on switch statements in case you don't know how to use them.
http://wiki.amxmodx.org/Pawn_Tutorial#Switch_Statements


Re: Making commands to randomly work? - davve95 - 28.10.2012

Quote:
Originally Posted by VincentDunn
View Post
example
pawn Code:
CMD:command(playerid, params[])
{
    switch(random(2))
    {
        case 1:
            SendClientMessage(playerid, -1, "Success!");
           
        default:
            SendClientMessage(playerid, -1, "Failed!");
    }
    return 1;
}
random(2) - %50 percent chance of succeeding
random(3) - %33 percent chance of succeeding
random(4) - %25 percent chance of succeeding
random(5) - %20 percent chance of succeeding

etc.

Heres a page on switch statements in case
you don't know how to use them.
http://wiki.amxmodx.org/
Pawn_Tutorial#Switch_Statements
Thanks alot!...
Can u check this to ?? :

https://sampforum.blast.hk/showthread.php?tid=388139