How do I prevent this (Command issue)
#1

Basically, I just made /spawncar so that you'll open a dialog if you're not in a car and then you'll be able to pick the car you want to spawn. Well it all works fine and dandy, but then I made a check to see if the player is in a car already, and if he is then it deletes the current vehicle. My question is, how do I make it so you pick another vehicle name, then it deletes the current one and spawns that one? My current vehicles are in the command, and I'll show the dialog bit if needed. I prefer to try to learn things on my own, so if anyone has any pages from the wiki that they think might help me, do share.

Код:
CMD:spawncar(playerid, params[])
{
	new currentvehicle;
	currentvehicle = GetPlayerVehicleID(playerid);
	
	if(IsPlayerInAnyVehicle(playerid))
	{
	
		DestroyVehicle(currentvehicle);
	}
	else
	{
    ShowPlayerDialog(playerid,12,DIALOG_STYLE_LIST,""COL_RED"Cars:",""COL_GREEN"Infernus\n"COL_GREEN"Elegy\n"COL_GREEN"Turismo\n"COL_GREEN"NRG\n"COL_GREEN"Comet\n"COL_GREEN"Huntley\n"COL_GREEN"Club\n","Select","Cancel");
    }
    return 1;
}
Reply
#2

I'd use this: put this before the next line:
Код:
DestroyVehicle(currentvehicle);
and then below it
Код:
currentvehicle = CreateVehicle()...
Reply
#3

You can use this one .I tested and it works :
Код:
CMD:spawncar(playerid, params[])
{
	new currentvehicle;
	currentvehicle = GetPlayerVehicleID(playerid);
	
	if(IsPlayerInAnyVehicle(playerid))
	{
	
		DestroyVehicle(currentvehicle);
                ShowPlayerDialog(playerid,12,DIALOG_STYLE_LIST,""COL_RED"Cars:",""COL_GREEN"Infernus\n"COL_GREEN"Elegy\n"COL_GREEN"Turismo\n"COL_GREEN"NRG\n"COL_GREEN"Comet\n"COL_GREEN"Huntley\n"COL_GREEN"Club\n","Select","Cancel")
	}
	else
	{
                ShowPlayerDialog(playerid,12,DIALOG_STYLE_LIST,""COL_RED"Cars:",""COL_GREEN"Infernus\n"COL_GREEN"Elegy\n"COL_GREEN"Turismo\n"COL_GREEN"NRG\n"COL_GREEN"Comet\n"COL_GREEN"Huntley\n"COL_GREEN"Club\n","Select","Cancel");
        }
        return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)