How to make random script ? - 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: How to make random script ? (
/showthread.php?tid=491568)
How to make random script ? -
barts - 31.01.2014
I want this script to do not 1 random cmd
I want to give cash or guns or something else, how to do it ?
Re: How to make random script ? -
Konstantinos - 31.01.2014
pawn Код:
switch (random(4))
{
case 0: GivePlayerMoney(playerid, 500);
case 1: GivePlayerWeapon(playerid, 24, 1000);
case 2: GivePlayerWeapon(playerid, 34, 1000);
case 3:
{
// something else..
}
}
Re: How to make random script ? -
Beckett - 31.01.2014
You mean a command like /givecash and there are randomized money given?
Код:
CMD:getmoney(playerid,params[])
{
new money = random(10000);
GivePlayerMoney(playerid,money);
}
Re: How to make random script ? -
barts - 31.01.2014
@Konstantinos how this work ?I want something like this
Re: How to make random script ? -
BroZeus - 31.01.2014
for example if u type random(5) then it will give any number between 1-4
so like this u can use "random()" command as per as your use
Re: How to make random script ? -
Beckett - 31.01.2014
Barts, It's like this.
Код:
CMD:getsomething(playerid,params[])
{
switch (random(2))
{
case 0: GivePlayerMoney(playerid, 500);
case 1: GivePlayerWeapon(playerid, 24, 1000);
case 2: GivePlayerWeapon(playerid, 34, 1000);
}
// Means that it will random those 3 cases, if its 1 then it will give the player 500, if its 2 then it'll give a weapon, etc.
// based on Konstantionos code.