Random gift on vehicle
#1

So,i'm scripting a random gifts when player enter in a vehicle.

Ex: 1 time money,then weapons,health etc.

There is a problem here:

pawn Код:
new RandomGIFT[][] =
{
    "new string[32];
     GivePlayerMoney(playerid, 2500);
     format(string, sizeof(string), "
BONUS GIFT! YOU GOT 2500$");
     SendClientMessage(playerid, COLOR_YELLOW, string);
    "
,
    "Random GIFT 2",
    "Random GIFT 3"
};
When i compile i got lot of general errors,what's wrong?
Reply
#2

Show us the error we are not code reader
Reply
#3

Quote:
Originally Posted by ScriptJorkis
Посмотреть сообщение
Show us the error we are not code reader
I get only general errors regarding the rest of gamemode code.
Reply
#4

This isn't PHP LOL.
Reply
#5

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
This isn't PHP LOL.
What?I wasn't talking about PHP.
Reply
#6

Instead of putting it into an array which wouldn't work in the first place, just make a stock function.

pawn Код:
#define MAX_RANDOM_GIFTS 3 //The amount of random gifts you have
stock RandomGift(playerid)
{
    new randomgift = random(MAX_RANDOM_GIFTS) + 1;
    switch (randomgift)
    {
        case 1:
        {
            //Do something
        }
        case 2:
        {
            //Do something 2
        }
        case 3:
        {
            //Do something 3
        }
    }
    return 1;
}
Reply
#7

Thanks,but what i've to add then OnPlayerEnterVehicle?Just "RandomGift(playerid)" ..?
Reply
#8

I would personally use it on OnPlayerStateChange as OnPlayerEnterVehicle is called when the player starts entering a vehicle, not when the player is actually in one.

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER) RandomGift(playerid);
    return 1;
}
Reply
#9

PHP код:
RandomGift(playerid); 
Reply
#10

Thanks,rep for both.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)