SA-MP Forums Archive
/boot combining - 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: /boot combining (/showthread.php?tid=476061)



/boot combining - whando - 16.11.2013

When I combine this 2 commands it bugs with other commands eg spawning a car with /veh. I just want /boot to open the boot and when I do it again it has to close the boot.

Код:
	if(strcmp(cmd, "/boot", true) == 0)
	{
        new vid = GetPlayerVehicleID(playerid);
		if(vid != INVALID_VEHICLE_ID)
		if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GRAD2, "You must be in a car before you can do this!");
		if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_GRAD2, "Only the driver can do this!");
		{
            GetPlayerName(playerid, sendername, sizeof(sendername));
			format(string, sizeof(string), "> %s Presses on the trunk button and opens it.", RemoveUnderScore(playerid));
			ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
//                                        ||||||
            SetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,VEHICLE_PARAMS_ON,objective);
        }
  return 1;
    }
	if(strcmp(cmd, "/closeboot", true) == 0 || strcmp(cmd, "/cboot", true) == 0)
	{
    new vid = GetPlayerVehicleID(playerid);
        if(vid != INVALID_VEHICLE_ID)
		if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GRAD2, "You must be in a car before you can do this!");
		if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_GRAD2, "Only the driver can do this!");
		{
            GetPlayerName(playerid, sendername, sizeof(sendername));
			format(string, sizeof(string), "> %s Presses on the trunk button and closes it.", RemoveUnderScore(playerid));
			ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
//                                        ||||||
            SetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,VEHICLE_PARAMS_OFF,objective);
        }
        return 1;
	}
Код:
	if(strcmp(cmd, "/boot", true) == 0)
	{
        new vid = GetPlayerVehicleID(playerid);
		if(vid != INVALID_VEHICLE_ID)
		if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GRAD2, "You must be in a car before you can do this!");
		if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_GRAD2, "Only the driver can do this!");
		{
            GetPlayerName(playerid, sendername, sizeof(sendername));
			format(string, sizeof(string), "> %s Presses on the trunk button and opens it.", RemoveUnderScore(playerid));
			ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
//                                        ||||||
            SetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,VEHICLE_PARAMS_ON,objective);
        }
  return 1;
    }
	else
	{
		new vid = GetPlayerVehicleID(playerid);
        if(vid != INVALID_VEHICLE_ID)
		if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GRAD2, "You must be in a car before you can do this!");
		if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_GRAD2, "Only the driver can do this!");
		{
            GetPlayerName(playerid, sendername, sizeof(sendername));
			format(string, sizeof(string), "> %s Presses on the trunk button and closes it.", RemoveUnderScore(playerid));
			ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
//                                        ||||||
            SetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,VEHICLE_PARAMS_OFF,objective);
        }
        return 1;
	}



Re: /boot combining - ]Rafaellos[ - 16.11.2013

pawn Код:
new IsBootOpen[MAX_PLAYERS] = 0;

if(strcmp(cmd, "/boot", true) == 0)
{
    new vid = GetPlayerVehicleID(playerid);
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GRAD2, "You must be in a car before you can do this!");
    if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_GRAD2, "Only the driver can do this!");
    if(IsBootOpen[playerid] == 0)
    {
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "> %s Presses on the trunk button and opens it.", RemoveUnderScore(playerid));
        ProxDetector(30.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
        SetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, VEHICLE_PARAMS_ON, objective);
        IsBootOpen[playerid] = 1;
    }
    else if(IsBootOpen[playerid] == 1)
    {
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "> %s Presses on the trunk button and closes it.", RemoveUnderScore(playerid));
        ProxDetector(30.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
        SetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, VEHICLE_PARAMS_OFF, objective);
        IsBootOpen[playerid] = 0;
    }
    return 1;
}
Not Tested.


Re: /boot combining - whando - 16.11.2013

Thanks, worked!