random pick
#1

hi im looking for a script that if i pick up and obect and then go /opencase it go to 1 of the following

Bomb(kill)

Rockets

Money

and each time someone opens it they will get 1 of these at random thx for your time
Reply
#2

is it something like this


Код:
//top of script 

new random;
{
if (strcmp("/opencase", cmdtext, true, 10) == 0)\

random

return 1;
}

now i need something here to say if he hase the case so like 
if(pickupid == Pickup)
random = 1 

if(random = 1)
then i need somehow to select a random thing

else

SendClientMessage (playerid, 0x33AA33AA , "you do not have the case");
Something like that im realy noob at this well not real noob just the hard stuff i dont know any way thats how i think it would work
Reply
#3

pawn Код:
if(!strcmp(cmdtext, "/opencase", true))
{
  new rand = random(3);
  switch(rand)
  {
    case 0:
    {
      // bomb
    }
    case 1:
    {
      // Rockets
    }
    case 2:
    {
      // Money
    }
  }
  return 1;
}
Reply
#4

ya cool but umm i have to make it so that can be used by the person holding the case
Reply
#5

Quote:
Originally Posted by sggassasin
ya cool but umm i have to make it so that can be used by the person holding the case
what variable do you use to identify whether the player is holding a case?
Use that variable and make it into an if statement.
Reply
#6

i dont have a varibal i think this is my script that im useing

Код:
//Top of scrip
new Pickup;
new PlayerMoney;
new PlayerMoneyPickup;
forward Timer(playerid);

public OnGameModeInit()
{
Pickup = CreatePickup(1210, 2, 2019.7742,1344.4839,10.8203);
Return 1;
}

new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
PlayerMoney = GetPlayerMoney(playerid);
PlayerMoneyPickup = CreatePickup(1210, 2, 2019.7742,1344.4839,10.8203);

if(!strcmp(cmdtext, "/opencase", true))
{
  new rand = random(3);
  switch(rand)
  {
    case 0:
    {
      SetPlayerHealth(playerid,0);
      SendClientMessage(playerid,0xFFFF00AA, "You Tripped The Explosive");
		}
    case 1:
    {
      GivePlayerWeapon(playerid, 35, 15);
      SendClientMessage(playerid,0xFFFF00AA, "You Got 15 Well packed rockets");
	  }
    case 2:
    {
      GivePlayerMoney(playerid,43631);
      SendClientMessage(playerid,0xFFFF00AA, "It is Your LUCKY day");
		}
  }
  return 1;
 }

public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == Pickup)
{
GivePlayerMoney(playerid, 1000);
SendClientMessage(playerid, 0x33AA33AA, "You Better Run They Gonna Whant That Money");
SetTimerEx("Timer", 40000, 0, "i", playerid);
DestroyPickup(Pickup);
return 1;
}

if(pickupid == PlayerMoneyPickup)
{
GivePlayerMoney(playerid, PlayerMoney);
DestroyPickup(PlayerMoneyPickup);
return 1;
}
return 1;
}

public Timer(playerid)
{
GivePlayerMoney(playerid, 1000);
SetTimerEx("Timer", 40000, 0, "i", playerid);
return 1;
}
Thats the script im useing for the whole case i dont think iv put a veribal in



EDIT: also with that if statement i dont know how it go coz i find it hard to this kinnda stuff but im learning so let me try


if((the veribale) == 1)
Rand = random(3)


or something like that i dont know just a gusse
Reply
#7

i need help plz
Reply
#8

ok iv got the verible now i know what it is so like what do i do with the if stament coz like dont i have to get play pos or something idk HELP!
Reply
#9

Something like this ?
Код:
// Top
new Pickup;
new Gift[200] = -1;

//connect/disconnect
Gift[playerid] = -1;

public OnGameModeInit()
{
	Pickup = CreatePickup(1210, 2, 2019.7742,1344.4839,10.8203);
	return 1;
}

if(!strcmp(cmdtext, "/opencase", true))
{
	if(Gift[playerid] != -1) {
		switch(Gift[playerid])
		{
			case 0:
			{
				SetPlayerHealth(playerid,0);
				SendClientMessage(playerid,0xFFFF00AA, "You Tripped The Explosive");
				Gift[playerid] = -1;
			}
			case 1:
			{
				GivePlayerWeapon(playerid, 35, 15);
				SendClientMessage(playerid,0xFFFF00AA, "You Got 15 Well packed rockets");
				Gift[playerid] = -1;
			}
			case 2:
			{
				GivePlayerMoney(playerid,43631);
				SendClientMessage(playerid,0xFFFF00AA, "It is Your LUCKY day");
				Gift[playerid] = -1;
			}
		}
	}else SendClientMessage(playerid,0xFFFF00AA, "U must first pick up case !");
	return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	if(pickupid == Pickup)
	{
		Gift[playerid] = random(3);
		SendClientMessage(playerid,0xFFFF00AA, "Type /opencase to check your gift");
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)