SA-MP Forums Archive
How do I prevent this (Command issue) - 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: How do I prevent this (Command issue) (/showthread.php?tid=486298)



How do I prevent this (Command issue) - K9IsGodly - 08.01.2014

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;
}



Re: How do I prevent this (Command issue) - offon - 08.01.2014

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



Re: How do I prevent this (Command issue) - amirab - 08.01.2014

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;
}