A easier code needed to removeplayerfromvehicle - 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: A easier code needed to removeplayerfromvehicle (
/showthread.php?tid=516083)
A easier code needed to removeplayerfromvehicle -
verlaj - 29.05.2014
well its kinda pretty annoying to give every vehicle a specific id new veh1; veh = createvehicle..etc
i am gonna replace that with enum but if someone can help me by giving a better code (easier one)
i was using this one which works so far
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == 2)
{
if(GetPlayerVehicleID(playerid) == tank1)
{
if(Soldier[playerid] == 1)
{
if(GetPlayerScore(playerid) >= 1500)
{
SendClientMessage(playerid,COLOR_WHITE,"You are now driving this Tank");
}
else
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,COLOR_WHITE,"You need 1500 scores to drive this");
}
}
Re: A easier code needed to removeplayerfromvehicle -
[NWA]Hannes - 29.05.2014
If you only want soldiers to be able to use Rhinos you could just check the GetVehicleModel if it's a Rhino.
pawn Код:
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 432) //432 is the model of the Rhino
{
if(Soldier[playerid] == 1)
{
if(GetPlayerScore(playerid) >= 1500)
{
SendClientMessage(playerid, COLOR_WHITE, "You are now driving this tank.");
}
else
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_WHITE, "You need a score of 1500 to drive this.");
}
}
}
Re: A easier code needed to removeplayerfromvehicle -
verlaj - 29.05.2014
worked ty, if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 432)
didnt really worked before tho maybe my bad
edit: wasnt really aware of that ******
Re: A easier code needed to removeplayerfromvehicle -
PT - 29.05.2014
or you can use an switch
something like this..
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == 2)
{
switch(GetPlayerVehicleID(playerid))
{
case tank1:
{
if(Soldier[playerid] == 1 && GetPlayerScore(playerid) >= 1500)
{
SendClientMessage(playerid,COLOR_WHITE,"You are now driving this Tank");
}
else
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,COLOR_WHITE,"You need 1500 scores to drive this");
}
}
// case .....
}
}
return 1;
}