Making commands to randomly work?
#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


Messages In This Thread
Making commands to randomly work? - by davve95 - 27.10.2012, 19:14
Re: Making commands to randomly work? - by NewerthRoleplay - 27.10.2012, 19:20
Re: Making commands to randomly work? - by davve95 - 27.10.2012, 19:36
Re: Making commands to randomly work? - by ReneG - 27.10.2012, 21:05
Re: Making commands to randomly work? - by davve95 - 28.10.2012, 07:47

Forum Jump:


Users browsing this thread: 1 Guest(s)