SA-MP Forums Archive
Random item - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Random item (/showthread.php?tid=122203)



Random item - (Jeff) - 20.01.2010

so i wanted that when a play does /dig he is given a random object
Код:
  new gRandomPlayerDig[2][3] = {
  PlayerInfo[pGunPowder] += 1
  PlayerInfo[pDrugs] += 1
  }
but it doesn't work (i took it from lvdm and edited it) i know I'm doing it wrong, but how to do it properly?


Re: Random item - Correlli - 20.01.2010

pawn Код:
/* (code for your "/dig" command) */
PlayerInfo[pGunPowder] += random(maxcell);
PlayerInfo[pDrugs] += random(maxcell);



Re: Random item - (Jeff) - 20.01.2010

Quote:
Originally Posted by Don Correlli
pawn Код:
/* (code for your "/dig" command) */
PlayerInfo[pGunPowder] += random(maxcell);
PlayerInfo[pDrugs] += random(maxcell);
could explain what the random does? and does this the player randomly either Drugs or GunPowder?


Re: Random item - Correlli - 20.01.2010

Quote:
Originally Posted by changeme
could explain what the random does?
https://sampwiki.blast.hk/wiki/Random

Quote:
Originally Posted by changeme
and does this the player randomly either Drugs or GunPowder?
Both.


Re: Random item - (Jeff) - 20.01.2010

Quote:
Originally Posted by Don Correlli
Quote:
Originally Posted by changeme
could explain what the random does?
https://sampwiki.blast.hk/wiki/Random

Quote:
Originally Posted by changeme
and does this the player randomly either Drugs or GunPowder?
Both.
I don't want it to give both...I want it to randomly give ONE of them, Could you tell me how to do that?


Re: Random item - timmehhh - 20.01.2010

Код:
new random;
random = random(2);

if(random == 1){

givedrugsorshit;

}else{

givemyumother;
}



Re: Random item - Correlli - 20.01.2010

You mean something like this?

pawn Код:
new
    myRandom;
myRandom = random(2);
if(myRandom == 0) PlayerInfo[pGunPowder] += 1;
else PlayerInfo[pDrugs] += 1;



Re: Random item - (Jeff) - 20.01.2010

Quote:
Originally Posted by Don Correlli
You mean something like this?

pawn Код:
new
    myRandom;
myRandom = random(2);
if(myRandom == 0) PlayerInfo[pGunPowder] += 1;
else PlayerInfo[pDrugs] += 1;
when i do /dig it will do Digging(playerid); and set a timer for it
when the timer is up i want it to give randomly either drugs or gun powder but only 1 so either 1g drugs or 1g gun power randomly


Re: Random item - (Jeff) - 21.01.2010

Help.