Making commands to randomly work?
#1

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

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

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!.
Reply
#4

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

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)