Lag cmds && vlock
#1

why does it lags every time i do a cmd?

next thing iz how to make a player unlock vehicle while outside the car?
Код:
CMD:vlock(playerid, params[])
{
    new engine, lights, alarm, doors, bonnet, boot, objective, vehicleid, string[128];
	if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You are not driving a vehicle.");
	if(vehicleid == 509 || vehicleid == 481 || vehicleid == 510) return SendClientMessage(playerid, COLOR_GREY, "Bicycles have no engine.");
	vehicleid = GetPlayerVehicleID(playerid);
	GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
	if(!doors)
	{
	    SetVehicleParamsEx(vehicleid, engine, lights, alarm, 1, bonnet, boot, objective);
	    format(string, sizeof(string), "* %s Locked there car doors.", RPN(playerid));
 		SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
	}
	else
	{
	    SetVehicleParamsEx(vehicleid, engine, lights, alarm, 0, bonnet, boot, objective);
	    format(string, sizeof(string), "* %s Unlocked there doors.", RPN(playerid));
 		SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
	}
	return 1;
}
Reply
#2

You would need to store a variable that stores what vehicle the player was driving which could lead to problems when you have multiple players locking and unlocking the same vehicle. It might be easier to just unlock the doors when the player gets out of the vehicle. There was a logic error in your command though (not setting vehicleid before using it).

pawn Код:
CMD:vlock(playerid, params[])
{
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
        return SendClientMessage(playerid, COLOR_GREY, "You are not driving a vehicle.");
       
    new vehicleid = GetPlayerVehicleID(playerid);
    if(vehicleid == 509 || vehicleid == 481 || vehicleid == 510)
        return SendClientMessage(playerid, COLOR_GREY, "Bicycles have no engine.");
       
    new
        engine,
        lights,
        alarm,
        doors,
        bonnet,
        boot,
        objective,
        string[128];
       
    GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    if(!doors)
    {
        SetVehicleParamsEx(vehicleid, engine, lights, alarm, 1, bonnet, boot, objective);
        format(string, sizeof(string), "* %s Locked there car doors.", RPN(playerid));
        SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        return 1;
    }
    else
    {
        SetVehicleParamsEx(vehicleid, engine, lights, alarm, 0, bonnet, boot, objective);
        format(string, sizeof(string), "* %s Unlocked there doors.", RPN(playerid));
        SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        return 1;
    }
}
Reply
#3

have have a enum for cars ids

enum TeamCars
{
GroveStreet,
Police
}
new Cars[TeamCars];

can you help me now thats just an example of how i have the team cars?! to do it now cuz im trying to aviod using enum

Edit:nm i tried something praying it would work it did
Код:
     new engine, lights, alarm, doors, bonnet, boot, objective, vehicleid, string[128], Float:vx, Float:vy, Float:vz;
	 if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You are not driving a vehicle.");
	 if(vehicleid == 509 || vehicleid == 481 || vehicleid == 510) return SendClientMessage(playerid, COLOR_GREY, "Bicycles have no engine.");
	 GetVehiclePos(vehicleid, vx, vy, vz);
	 if(IsPlayerInRangeOfPoint(playerid, 3, vx, vy, vz))
	 vehicleid = GetPlayerVehicleID(playerid);
	 GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
Reply
#4

What about y my cmds are lagging? when i type them in? like a whole minute b4 cmd happens
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)