SA-MP Forums Archive
Spawn car for skin - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Spawn car for skin (/showthread.php?tid=66825)



Spawn car for skin - Faust - 24.02.2009

Hello ppl. I'm trying to make a command with what player spawns a car. But I need so skin ID 23 spawns a car with ID 457 and so on. How to check what skin ID player has? And how to put it in a command?



Re: Spawn car for skin - Dreftas - 24.02.2009

pawn Код:
if(!strcmp("/spawncar", cmdtext, true))
            {
            new skin;
            skin = GetPlayerSkin(playerid);
            if(skin == 23)
            {
            new Float:x, Float:y, Float:z, Float:a;
            GetPlayerPos(playerid,x,y,z);
            GetPlayerFacingAngle(playerid,a);
            CreateVehicle(457,x,y-4,z,a,0,1,99999) // 99999 - car respawn delay
            }
            else
                {
            SendClientMessage(playerid,0x0080FFFF,"You must have skin id 23 to use this command");
                }
            return 1;
            }
Under
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])



Re: Spawn car for skin - Faust - 24.02.2009

Ok, this is my command. In my script skins are given in random so if player dies and spawns with new skin, he gets the car what he had spawned first. How can I make it so when player spawns again the last spawned car disapears and creates new one? I hope you will understand what I ment.
Код:
	if (strcmp(cmdtext, "/car", true)==0) {
		new Float:X, Float:Y, Float:Z, Float:Angle;
		if(Start != 1) {
			return SendClientMessage(playerid, COLOR_GREY, "blah blah blah");
		}
		GetPlayerPos(playerid, X, Y, Z);
		GetPlayerFacingAngle(playerid, Angle);
		if(Carer[playerid] == 1) {
  	  if(IsAnyPlayerInVehicle(Veh[playerid])) {
				for(new i=0; i<GetMaxPlayers(); i++) {
				  if(GetPlayerVehicleID(i) == Veh[playerid]) {
				    RemovePlayerFromVehicle(i);
					}
				}
			}
			PutPlayerInVehicle(playerid, Veh[playerid], 0);
			SetVehiclePos(Veh[playerid], X, Y, Z);
			SetVehicleZAngle(Veh[playerid], Angle);
		} else {
			Carer[playerid] = 1;
			skin = GetPlayerSkin(playerid);
			if(skin == 283){
			Veh[playerid] = CreateVehicle(599, X, Y, Z+50, Angle, 0, 0, 10000);
			}
			else if(skin == 165){
			Veh[playerid] = CreateVehicle(490, X, Y, Z+50, Angle, 0, 0, 10000);
			}
			else if(skin == 285){
			Veh[playerid] = CreateVehicle(528, X, Y, Z+50, Angle, 0, 0, 10000);
			}
			else if(skin == 282){
			Veh[playerid] = CreateVehicle(598, X, Y, Z+50, Angle, 0, 0, 10000);
			}
			else if(skin == 280){
			Veh[playerid] = CreateVehicle(596, X, Y, Z+50, Angle, 0, 0, 10000);
			}
			else if(skin == 281){
			Veh[playerid] = CreateVehicle(597, X, Y, Z+50, Angle, 0, 0, 10000);
			}
			PutPlayerInVehicle(playerid, Veh[playerid], 0);
			SetVehiclePos(Veh[playerid], X, Y, Z);
			SetVehicleZAngle(Veh[playerid], Angle);
			return 1;
		}
	}
	return 0;
}