/car command - 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: /car command (
/showthread.php?tid=64350)
/car command -
Faust - 03.02.2009
Hello there .. Today I need your help with /car command. I need when player types /car he spawns car with him into it, but when he exits it and again types /car he got that car back and doesn't spawn new one. How can I do that?
Re: /car command -
Nero_3D - 03.02.2009
check in the car command if he already spawned one and if he did just set the vehicle position to yours
Re: /car command -
Faust - 03.02.2009
I have come so far.
Код:
new Mashina=0;
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp(cmdtext, "/vrum", true)==0)
{
Mashina=1;
new Float:X, Float:Y, Float:Z, Float:Angle;
new Car;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Angle);
Car = CreateVehicle(457, X, Y, Z + 3, Angle, 0, 1, 30);
PutPlayerInVehicle(playerid, Car, 0);
return 1;
}
What I need to put in brackets and after that where should I put that line?
Re: /car command -
Lazarus - 03.02.2009
@Faust, ehhhh.
pawn Код:
//top of script
new veh[MAX_PLAYERS] -1;
//command
if(strcmp(cmdtext, "/car", true, 4) == 0)
{
if(IsPlayerInAnyVehicle(playerid) == 1) return SendClientMessage(playerid, 0xFFFFFFFF, "You are already in a vehicle");
if(veh[playerid] != -1) return PutPlayerInVehicle(playerid, veh[playerid], 0);
if(strlen(cmdtext[5]) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /car [ID]");
if(strval(cmdtext[5]) >= 400 || strval(cmdtext[5]) <= 611) return SendClientMessage(playerid, 0xFFFFFFFF, "Invalid vehicle ID - weedarr.wikidot.com/vehlist");
new Float:X, Float:Y, Float:Z, Float:A;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, A);
veh[playerid] = CreateVehicle(strval(cmdtext[5]), X, Y, Z, A, -1, -1, -1);
PutPlayerInVehicle(playerid, veh[playerid], 0);
return 1;
}
//onplayerconnect
if(veh[playerid] != -1) DestroyVehicle(veh[playerid]);
veh[playerid] = -1;
Re: /car command -
Faust - 03.02.2009
Hey, thanks a lot, mate!
Re: /car command -
Faust - 05.02.2009
EDIT: Nevermind.