/car command
#1

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?
Reply
#2

check in the car command if he already spawned one and if he did just set the vehicle position to yours
Reply
#3

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?
Код:
if(Mashina==0){...}
Reply
#4

@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;
Reply
#5

Hey, thanks a lot, mate!
Reply
#6

EDIT: Nevermind.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)