/boot combining
#1

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;
	}
Reply
#2

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.
Reply
#3

Thanks, worked!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)