SA-MP Forums Archive
How to define a vehicle with a special vehicle id - 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: How to define a vehicle with a special vehicle id (/showthread.php?tid=491215)



How to define a vehicle with a special vehicle id - EmilLykke - 29.01.2014

What I did was

pawn Код:
public OnGameModeInit()
    {
        new Hotwire1 = AddStaticVehicle(549, 1669.7079, 1286.9500, 10.5176, 359.8699, 75, 39);
        }
How do I define the vehicle?


Re: How to define a vehicle with a special vehicle id - jakejohnsonusa - 29.01.2014

It is defined, by the variable "Hotwire1"

What are you trying to do with the defined vehicle?


Re: How to define a vehicle with a special vehicle id - EmilLykke - 29.01.2014

pawn Код:
command(hotwire, playerid, params[])
    {
        if(GetPlayerVehicleID(playerid) == Hotwire1)
        {
            SetTimerEx("Hotwiring", 2000, false, "i", playerid);
            GameTextForPlayer(playerid, "~r~Hotwiring", 5000, 1);
        }
    }
   
    forward Hotwiring(playerid);
    public Hotwiring(playerid)
    {
        new string[200], pstring[200];
        SetTimerEx("Hotwiring1", 1000*5, false, "i", playerid);
        format(string, sizeof(string), "You have taken out your toolbox, afterwards taking out a hammer from the toolbox, smashing the bottom dashboard.");
        SendClientMessage(playerid, ACTION, string);
        format(pstring, sizeof(pstring), "%s has taken out his toolbox, afterwards taking out a hammer from it, smashing the bottom dashboard.");
        SetPlayerChatBubble(playerid, pstring, ACTION, 30.0, 1000*5);  
    }
   
    forward Hotwiring2(playerid);
    public Hotwiring2(playerid)
    {
        new string[200], pstring[200];
        SetTimerEx("Hotwiring2", 1000*5, false, "i", playerid);
        format(string, sizeof(string), "hi");
        SendClientMessage(playerid, ACTION, string);
        format(pstring, sizeof(pstring), "hi");
        SetPlayerChatBubble(playerid, pstring, ACTION, 30.0, 1000*5);
    }
What I did so far


Re: How to define a vehicle with a special vehicle id - jakejohnsonusa - 29.01.2014

Is it not working? Well, first the code above is missing return's. Also, there is a better (working) way of defining the vehicle.

Try this:

pawn Код:
//Include at the top of your script (with all the other defined variables)
new Hotwire1[1];//The 1 represents the number of vehicles within Hotwire1, each will have it's own ID attached with Hotwire1.

public OnGameModeInit()    
{
      Hotwire1[0] = AddStaticVehicleEx(549, 1669.7079, 1286.9500, 10.5176, 359.8699, 75, 39);//Yeah, 0 is a number here, but not when we defined it... kind of confusing.
      //Rest of OnGameModeInit code...
      return 1;
}

command(hotwire, playerid, params[])    
{
        if(GetPlayerVehicleID(playerid) == Hotwire1[0])        
        {            
              SetTimerEx("Hotwiring", 2000, false, "i", playerid);            
              GameTextForPlayer(playerid, "~r~Hotwiring", 5000, 1);
              return 1;      
        }    
}

//Timers just like you have them above, BUT YOU NEED RETURNS! (return 1; at the end of everything).