SA-MP Forums Archive
Getcar and gotocar put me in blueberry if the car id doesnt exist. - 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: Getcar and gotocar put me in blueberry if the car id doesnt exist. (/showthread.php?tid=455500)



Getcar and gotocar put me in blueberry if the car id doesnt exist. - lramos15 - 02.08.2013

I get put in blueberry acres if the car id doesn't exist and I'm falling how do I fix that?
HTML Code:
//get car
CMD:getcar(playerid,params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 4)
 	{
 	    new Float:x, Float:y, Float:z;
		new vehicle,string[128];
		if(sscanf(params,"i",vehicle)) SendClientMessage(playerid, COLOR_RED, "Usage: /getcar [vehicleid]");
		GetPlayerPos(playerid, x, y, z);
		SetVehiclePos(vehicle, x, y+1, z);
        format(string,128,"You brought carid %i to you. ", vehicle);
		SendClientMessage(playerid,COLOR_YELLOW,string);
    }
   	else return SendClientMessage(playerid, COLOR_RED, "You are not a level 4 admin!");
	return 1;
}
//goto car
CMD:gotocar(playerid,params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 4)
 	{
 	    new Float:x, Float:y, Float:z;
		new vehicle,string[128];
		if(sscanf(params,"i",vehicle)) SendClientMessage(playerid, COLOR_RED, "Usage: /gotocar [vehicleid]");
		GetVehiclePos(vehicle, x, y, z);
		SetPlayerPos(playerid, x,y+1,z);
        format(string,128,"You have been teleported to. carid %i. ", vehicle);
		SendClientMessage(playerid,COLOR_YELLOW,string);
    }
   	else return SendClientMessage(playerid, COLOR_RED, "You are not a level 4 admin!");
	return 1;
}



Re: Getcar and gotocar put me in blueberry if the car id doesnt exist. - PrinceKumar - 02.08.2013

Put this line under your codes
pawn Code:
new vehicle;
if(vehicle >=612 || vehicle <=399) return sendclientmessage(playerid, color, "vehicleid does not exists);// after sscanf line
// or u can use invalid_vehicle_id



Re: Getcar and gotocar put me in blueberry if the car id doesnt exist. - lramos15 - 02.08.2013

I'm setting car position not spawning them


Re: Getcar and gotocar put me in blueberry if the car id doesnt exist. - Ada32 - 02.08.2013

Code:
 if(vehicle == INVALID_VEHICLE_ID) {

 }