SA-MP Forums Archive
Infernus special 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)
+--- Thread: Infernus special command. (/showthread.php?tid=600201)



Infernus special command. - ProRakNet - 05.02.2016

Hi, infernus(411) special command how do I add..

How do I add ?
if(IsPlayerInVehicle(playerid, 411)){

PHP код:
if(strcmp(cmd"/infobject"true) == 0)
{
if(
IsPlayerInAnyVehicle(playerid))
{
if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER){ SendClientMessage(playerid, -1"{FFFFFF}You must be the driver!");return 1;}
ShowPlayerDialog(playeridVehDialogDIALOG_STYLE_LIST"{FFFFFF}Infernus Vehicle Objects""{FFFFFF}Object 1\n Object2\n {FFFFFF}Object 3\n {FFFFFF}Object 4""Select""Cancel");
}
else
{
SendClientMessage(playerid, -1"{FFFFFF}You are not in any car!");
}
return 
1;




Re: Infernus special command. - Mencent - 05.02.2016

PHP код:
if(strcmp(cmd"/infobject"true) == 0)
{
    new 
vehicleid GetPlayerVehicleID(playerid);
    if(!
vehicleid)return SendClientMessage(playerid, -1"{FFFFFF}You are not in any car!");
    if(
GetVehicleModel(vehicleid) == 411)
    {
        if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER){ SendClientMessage(playerid, -1"{FFFFFF}You must be the driver!");return 1;}
        
ShowPlayerDialog(playeridVehDialogDIALOG_STYLE_LIST"{FFFFFF}Infernus Vehicle Objects""{FFFFFF}Object 1\n Object2\n {FFFFFF}Object 3\n {FFFFFF}Object 4""Select""Cancel");
    }
    return 
1;

You have to use GetVehicleModel to check if the player (driver of vehicleid) is in vehicle 411.


Re: Infernus special command. - Sascha - 05.02.2016

"vehicleid" is not the same as "modelid"
IsPlayerInAnyVehicle only checks if a player is in a vehicle at all.
GetPlayerVehicleID will give you the ID the player is in (not the model!)
Each vehicle as a unique ID assigned to by the server, so the server can seperate between each single vehicle. This makes it possible to detect a certain vehicle if you are only using infernusses on your server.
GetVehicleModel will give you the model of the vehicle (infernus, turismo, etc)

you can use it like this:
Код:
if(strcmp(cmd, "/infobject", true) == 0) 
{ 
	if(IsPlayerInAnyVehicle(playerid)) 
	{ 
		new vehicleid = GetPlayerVehicleID(playerid);
		if(GetVehicleModel(vehicleid) == 411)
		{
			if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER){ SendClientMessage(playerid, -1, "{FFFFFF}You must be the driver!");return 1;} 
			ShowPlayerDialog(playerid, VehDialog, DIALOG_STYLE_LIST, "{FFFFFF}Infernus Vehicle Objects", "{FFFFFF}Object 1\n Object2\n {FFFFFF}Object 3\n {FFFFFF}Object 4", "Select", "Cancel"); 
		}
		else
		{
			SendClientMessage(playerid, -1, "Only possible in an infernus");
		}
	}
	else 
	{	 
		SendClientMessage(playerid, -1, "{FFFFFF}You are not in any car!"); 
	} 
	return 1; 
}
@Mencent: https://sampwiki.blast.hk/wiki/GetVehicleModel
The useage is not "GetVehicleModel(vehicleid, modelitshouldbe)" it is "GetVehicleModel(vehicleid)" and will return the modelid

So this won't work:
Quote:
Originally Posted by Mencent
Посмотреть сообщение
PHP код:
if(strcmp(cmd"/infobject"true) == 0)
{
    new 
vehicleid GetPlayerVehicleID(playerid);
    if(!
vehicleid)return SendClientMessage(playerid, -1"{FFFFFF}You are not in any car!");
    if(
GetVehicleModel(vehicleid,411))
    {
        if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER){ SendClientMessage(playerid, -1"{FFFFFF}You must be the driver!");return 1;}
        
ShowPlayerDialog(playeridVehDialogDIALOG_STYLE_LIST"{FFFFFF}Infernus Vehicle Objects""{FFFFFF}Object 1\n Object2\n {FFFFFF}Object 3\n {FFFFFF}Object 4""Select""Cancel");
    }
    return 
1;

You have to use GetVehicleModel to check if the player (driver of vehicleid) is in vehicle 411.



Re: Infernus special command. - ProRakNet - 07.02.2016

very thanks worked.


Re: Infernus special command. - Mencent - 07.02.2016

Quote:
Originally Posted by Sascha
Посмотреть сообщение
@Mencent: https://sampwiki.blast.hk/wiki/GetVehicleModel
The useage is not "GetVehicleModel(vehicleid, modelitshouldbe)" it is "GetVehicleModel(vehicleid)" and will return the modelid
Oh, yes! Of yourse, thank you! I forgot it..