Random item
#1

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

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

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?
Reply
#4

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

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?
Reply
#6

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

if(random == 1){

givedrugsorshit;

}else{

givemyumother;
}
Reply
#7

You mean something like this?

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

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

Help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)