SA-MP Forums Archive
[Help]Vehicle Spawn - 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: [Help]Vehicle Spawn (/showthread.php?tid=515703)



[Help]Vehicle Spawn - herligho232 - 27.05.2014

Hello.

I'm trying to create a command that will be created vehicle called the player and only he could enter it. The problem is that I can not enter the vehicle created.

code :
Код:
// on top of a map
new Player[MAX_PLAYERS];

// command :

CMD:v(playerid, params[])
{
	if(vInfo[playerid][VMODEL] != 0 && vZespawnowany[playerid] == 0)
	{
		Player[playerid] = CreateVehicle(vInfo[playerid][VMODEL], vInfo[playerid][VPX], vInfo[playerid][VPY], vInfo[playerid][VPZ], vInfo[playerid][VOBROT], vInfo[playerid][VCOLOR2], vInfo[playerid][VCOLOR2], 600);
		SendClientMessage(playerid,COLOR_YELLOW,"Zespawnowałeś swуj pojazd !");
		vZespawnowany[playerid] = 1;
	}
	else if(vZespawnowany[playerid] == 1)
	{
		SendClientMessage(playerid,COLOR_RED,"Twуj pojazd jest już zespawnowany !");
	}
	else if(vInfo[playerid][VMODEL] == 0)
	{
        SendClientMessage(playerid,COLOR_RED,"Nie masz pojazdu !");
	}
	return 1;
}

// function for the player ejected from the vehicle :

if(GetPlayerVehicleID(playerid) != uauto1 || GetPlayerVehicleID(playerid) != uauto2 || GetPlayerVehicleID(playerid) != uauto3 || GetPlayerVehicleID(playerid) != uauto4)
{
	if(GetPlayerVehicleID(playerid) != Player[MAX_PLAYER_NAME])
	{
		RemovePlayerFromVehicle(playerid);
		SendClientMessage(playerid, COLOR_RED, "To nie twуj pojazd , wysiadaj");
	}
	else if(GetPlayerVehicleID(playerid) == Player[MAX_PLAYER_NAME])
	{
	}
}
Sorry for my bad english :P


Re: [Help]Vehicle Spawn - Konstantinos - 27.05.2014

That is wrong:
pawn Код:
Player[MAX_PLAYER_NAME]
It should be:
pawn Код:
Player[playerid]
and you don't have to use "else if":
pawn Код:
if(GetPlayerVehicleID(playerid) != Player[playerid])
{
    RemovePlayerFromVehicle(playerid);
    SendClientMessage(playerid, COLOR_RED, "To nie twуj pojazd , wysiadaj");
}
else
{
    // code.. the vehicle is for that player
}



Re: [Help]Vehicle Spawn - herligho232 - 27.05.2014

Thanks, everything works. Reputation for you.