Giving a random amount of cash or score. - 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: Giving a random amount of cash or score. (
/showthread.php?tid=392068)
Giving a random amount of cash or score. -
Elysian` - 12.11.2012
Hello, I wanna know how I'd make a custom amount of time for a pickup to respawn where it gives a random amount of score or cash and would spawn in 3 different places..
I.E, it'd spawn in one place, a player picks it up, it respawns 20 minutes later on another place.
Picking this up will give you a random amount of score or cash, how can I do this?
Re: Giving a random amount of cash or score. -
SuperViper - 12.11.2012
pawn Код:
forward public CreateRewardPickup();
new rewardPickup, Float: spawnLocations[][3] =
{
{0.0, 0.0, 0.0},
{0.0, 0.0, 0.0},
{0.0, 0.0, 0.0}
};
public OnGameModeInit()
{
CreateRewardPickup();
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == rewardPickup)
{
DestroyPickup(rewardPickup);
SetTimer("CreateRewardPickup", 1200000, 0);
GivePlayerMoney(playerid, random(20000));
SetPlayerScore(playerid, GetPlayerScore(playerid) + random(10));
new clientMessage[60];
GetPlayerName(playerid, clientMessage, MAX_PLAYER_NAME);
format(clientMessage, sizeof(clientMessage), "%s has found the reward token.", clientMessage);
SendClientMessageToAll(-1, clientMessage);
}
return 1;
}
public CreateRewardPickup()
{
new randomSpawn = random(sizeof(spawnLocations));
rewardPickup = CreatePickup(1239, 23, spawnLocations[randomSpawn][0], spawnLocations[randomSpawn][1], spawnLocations[randomSpawn][2]);
return 1;
}
Re: Giving a random amount of cash or score. -
Elysian` - 12.11.2012
Thanks, Rep++
Re: Giving a random amount of cash or score. -
Face9000 - 12.11.2012
Maybe this isn't what you asked for but it will come in handly if you need it
pawn Код:
new mrand =random(5); //Numbers randomly selected from 1 to 5
SetPlayerScore(playerid, GetPlayerScore(playerid) +mrand); //Give at the player a random ammount of score defined above (a number from 1 to 5).
//Or with money:
new cashrandom=random(15000); //Same as above, select a a number randomly from 1 to 15000.
GivePlayerMoney(playerid,cashrandom); //Give at the player a random ammount of money by the random value generated above.