SA-MP Forums Archive
Car cmd - 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 cmd (/showthread.php?tid=365415)



Car cmd - xSkullx - 02.08.2012

Hi everybody i have this car cmd edited from an admin system and it spawn a car next to me, but i want to spawn me in car. What i have to do?
Код:
dcmd_car(playerid,params[]) {
	if(PlayerInfo[playerid][Level] >= 0) {
	    new tmp[256], tmp2[256], tmp3[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index); tmp3 = strtok(params,Index);
	    if(!strlen(tmp)) return SendClientMessage(playerid, red, "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, red, "{FC0303}EROARE{00FF19}: {FC0303}ID de vehicul invalid");
		if(!strlen(tmp2)) colour1 = random(126); else colour1 = strval(tmp2);
		if(!strlen(tmp3)) colour2 = random(126); else colour2 = strval(tmp3);
		if(PlayerInfo[playerid][pCar] != -1 && !IsPlayerAdmin(playerid) ) CarDeleter(PlayerInfo[playerid][pCar]);
		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+3,Y,Z, Angle, colour1, colour2, -1); LinkVehicleToInterior(LVehicleID,int1);
		PlayerInfo[playerid][pCar] = LVehicleID;
        SaveToFile("CarSpawns",string);
		format(string, sizeof(string), "{00FF19}You have spawned a {FC0303}\"%s\" {FFFFFF}({00FF19}Model:{FC0303}%d{FFFFFF})", VehicleNames[car-400], car);
		return SendClientMessage(playerid,lightblue, string);
	} else return SendClientMessage(playerid,red,"ERROR: You need to be level 3 to use this command");
}
Thanks.


Re: Car cmd - Viiih - 02.08.2012

PutPlayerInVehicle(playerid, vehicleid, 0);
So, I'll get it on your variables:
PutPlayerInVehicle(playerid, car, 0); //0 = Driver
Just ADD it after spawning the vehicle.