SA-MP Forums Archive
Random gift on vehicle - 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: Random gift on vehicle (/showthread.php?tid=310443)



Random gift on vehicle - Face9000 - 12.01.2012

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?


Re: Random gift on vehicle - ScriptJorkis - 12.01.2012

Show us the error we are not code reader


Re: Random gift on vehicle - Face9000 - 12.01.2012

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.


Re: Random gift on vehicle - Lorenc_ - 12.01.2012

This isn't PHP LOL.


Re: Random gift on vehicle - Face9000 - 12.01.2012

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


Re: Random gift on vehicle - [HiC]TheKiller - 12.01.2012

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;
}



Re: Random gift on vehicle - Face9000 - 12.01.2012

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


Re: Random gift on vehicle - [HiC]TheKiller - 12.01.2012

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;
}



Re: Random gift on vehicle - Mrki_Drakula - 12.01.2012

PHP код:
RandomGift(playerid); 



Re: Random gift on vehicle - Face9000 - 12.01.2012

Thanks,rep for both.