Giving a random amount of cash or score.
#1

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

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;
}
Reply
#3

Thanks, Rep++
Reply
#4

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


Forum Jump:


Users browsing this thread: 1 Guest(s)