Trunk won't open
#1

What is wrong with this code? The trunk won't open.

pawn Код:
CMD:trunk(playerid)
{
    new engine,lights,alarm,doors,bonnet,boot,objective, Float:X, Float:Y, Float:Z, string[90];
    for(new vid = 0; vid < MAX_VEHICLES; vid++){
        if(vid != INVALID_VEHICLE_ID) {
            GetVehiclePos(vid, X, Y, Z);
            if(!IsPlayerInRangeOfPoint(playerid, 5, X, Y, Z)) return 1;
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            if(boot == VEHICLE_PARAMS_ON){
                SetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,VEHICLE_PARAMS_OFF,objective);
                format(string, sizeof(string), "closes the trunk of %s.", GetVehicleName(vid));
                return PlayerActionMsg(playerid, string);
            }
            SetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,VEHICLE_PARAMS_ON,objective);
            format(string, sizeof(string), "opens the trunk of %s.", GetVehicleName(vid));
            return PlayerActionMsg(playerid, string);
        }
    }
    return 1;  
}
Reply
#2

Instead of Vehicle params on just put 1.
Reply
#3

https://sampforum.blast.hk/showthread.php?tid=305771

Try my include -> it has everything connected to vehicles (boot, boonet, doors, etc.)
Reply
#4

Quote:
Originally Posted by fiki574_CRO
Посмотреть сообщение
https://sampforum.blast.hk/showthread.php?tid=305771

Try my include -> it has everything connected to vehicles (boot, boonet, doors, etc.)
Will check it out, but first I wanna do it this way.

Now I have another problem. When I type /trunk close for the first time, it says * My_Name closed the trunk of the [car name], but the problem is, the trunk is closed already. After that first time, the command works okay, just that first time is messed up.

This is my code for the cmd:
pawn Код:
if (strcmp("close", option, true, 5) == 0){
    GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
    if(boot == 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR:] The trunk is already closed.");
                                      SetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,VEHICLE_PARAMS_OFF,objective);
        format(string, sizeof(string), "closes the trunk of %s.", GetVehicleName(vid));
        return PlayerActionMsg(playerid, string);
}
And OnVehicleSpawn and stream in:
pawn Код:
public OnVehicleSpawn(vehicleid)
{
    new engine,lights,alarm,doors,bonnet,boot,objective
   
    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
    SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,0,0,objective);
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    new engine,lights,alarm,doors,bonnet,boot,objective
   
    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
    SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)