/engine
#1

This command works fine, however, sometimes when you try to start the vehicle's engine it takes up to 5 seconds before it actually works...There isn't that much code there, so I dunno what the issue could me. It's not lag from the server, because i tried it on localhost.

pawn Код:
CMD:engine(pid)
{
    if(IsPlayerInAnyVehicle(pid))
    {
        new id = GetPlayerVehicleID(pid);
        if(VBroke[id] == 1) return ErrorMessage(pid, "Vehicle is broken or out of fuel.");
        if(VehicleInfo[id][vRented] == pid || VehicleInfo[id][vFaction] == PlayerInfo[pid][pFaction] || strmatch(VehicleInfo[id][vOwner], GetName(pid)))
        {
            new engine, lights, alarm, doors, bonnet, boot, objective, string[100];
            GetVehicleParamsEx(id, engine, lights, alarm, doors, bonnet, boot, objective);
            if(engine == 0)
            {
                SetVehicleParamsEx(id, 1, lights, alarm, doors, bonnet, boot, objective);
                format(string, sizeof(string), "twists the key, starting the engine of the %s.", GetVehicleFriendlyName(id));
                MeMessage(pid, string);
                return 1;
            }
            else
            {
                SetVehicleParamsEx(id, 0, lights, alarm, doors, bonnet, boot, objective);
                format(string, sizeof(string), "twists the key, shutting off the engine of the %s.", GetVehicleFriendlyName(id));
                MeMessage(pid, string);
                return 1;
            }
        }
        else return ErrorMessage(pid, "You don't have a key for this vehicle.");
    }
    else return ErrorMessage(pid, "You aren't in a vehicle.");
}
Reply
#2

Doesn't matter if you tried it in localhost - If your script is not properly done and has lots of bottlenecks any script executed will have lag regardless of your ping.

What happens with the message? Does it also take 5 seconds to be sent, or it does get sent instantly after typing the command?
Reply
#3

Quote:
Originally Posted by CuervO
Посмотреть сообщение
Doesn't matter if you tried it in localhost - If your script is not properly done and has lots of bottlenecks any script executed will have lag regardless of your ping.

What happens with the message? Does it also take 5 seconds to be sent, or it does get sent instantly after typing the command?
i know it has bottlenecks, that's why I was trying to prevent comments "shit host get new one"

The engine/message does not come up until about 5 seconds after typnig the command sometimes, however, other times it works fine
Reply
#4

Quote:
Originally Posted by Mattakil
Посмотреть сообщение
i know it has bottlenecks, that's why I was trying to prevent comments "shit host get new one"

The engine/message does not come up until about 5 seconds after typnig the command sometimes, however, other times it works fine
Then it most likely has to do with the script itself, not the command; what do you do before using that command? Check OnPlayerEnterVehicle or OnPlayerStateChange (whatever you use) for very big loops or data checks. It could be anything, basically...

GetVehicleFriendlyName(), or even MeMessage().
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)