SA-MP Forums Archive
/car issue - 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: /car issue (/showthread.php?tid=587086)



/car issue - YoussefHammad - 27.08.2015

i'm trying to make that if the player is already in a vehicle , it sends him the msg (You are already in a vehicle) , and when he spawns a vehicle the old vehicle he spawned should be destroyed , however , neither of the 2 conditions happen. In fact it sends the msg (You are already in a vehicle) if im NOT in a vehicle and vice versa
Код:
CMD:car(playerid,params[])
{
	if(IsPlayerInAnyVehicle(playerid))
	{
 		SendClientMessage(playerid,-1,"You are already in a vehicle!");
	}
	else
	{
	    new vehspawned;
	    vehspawned = 0;
	    new vehicleid;
		vehicleid = GetPlayerVehicleID(playerid);
	    if(vehspawned == 1)
	    {
			DestroyVehicle(vehicleid);
			vehspawned = 0;
	    }
        new tmp[128], tmp2[128], tmp3[128], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index); tmp3 = strtok(params,Index);
        if(isnull(tmp)) return SendClientMessage(playerid, -1, "USAGE: /car [Modelid/Name] [colour1] [colour2]");
        new car, colour1, colour2, string[128];
        if(!IsNumeric(tmp)) car = GetVehicleModelIDFromName(tmp); else car = strval(tmp);
        if(car < 400 || car > 611) return  SendClientMessage(playerid, -1, "ERROR: Invalid Vehicle Model");
        if(isnull(tmp2)) colour1 = random(126); else colour1 = strval(tmp2);
        if(isnull(tmp3)) colour2 = random(126); else colour2 = strval(tmp3);
		new LVehicleID,Float:X,Float:Y,Float:Z, Float:Angle,int1;    GetPlayerPos(playerid, X,Y,Z);    GetPlayerFacingAngle(playerid,Angle);   int1 = GetPlayerInterior(playerid);
        LVehicleID = CreateVehicle(car, X,Y,Z, Angle, colour1, colour2, -1); LinkVehicleToInterior(LVehicleID,int1);
        format(string, sizeof(string), "You have spawned a \"%s\" (Model:%d) colour (%d, %d)", VehicleName[car-400], car, colour1, colour2);
        PutPlayerInVehicle(playerid, LVehicleID, 0);
        VehicleInfo[LVehicleID][Temp] = 1;
        vehspawned = 1;
        return SendClientMessage(playerid,-1, string);
	}
	return 1;
}
tell me if u want any other codes , Thanks