Make these commands to work faster..
#1

Hey,
Atm I only know how to make commands with dcmd.. And idk.. some commands take about 2-4 seconds to process..
Here are two of them:

pawn Код:
dcmd_goto(playerid,params[]) // This command teleports me to player
{
    if (dUserINT(PlayerName(playerid)).("Adminlvl")>=2)
    {
        new id, Float:x,Float:y,Float:z;
        if (sscanf(params, "u", id)) UsageMsg(playerid, "USAGE: /goto <PlayerID/PartOfName>");
        else if (id == INVALID_PLAYER_ID) ErrorMsg(playerid, "Player not found");
        else
        {
            GetPlayerPos(id,x,y,z);
            new interior = GetPlayerInterior(id);
            SetPlayerInterior(playerid,interior);
            SetPlayerPos(playerid,x,y+2,z+1);
        }
    }
    return 1;
}

dcmd_getplayer(playerid,params[]) //This command teleports player to me
{
    if (dUserINT(PlayerName(playerid)).("Adminlvl")>=2)
    {
        new id, Float:x,Float:y,Float:z;
        if (sscanf(params, "u", id)) UsageMsg(playerid, "USAGE: /getplayer <PlayerID/PartOfName>");
        else if (id == INVALID_PLAYER_ID) ErrorMsg(playerid, "Player not found");
        else
        {
          if (IsPlayerInAnyVehicle(id)) RemovePlayerFromVehicle(id);
            GetPlayerPos(playerid,x,y,z);
            SetPlayerPos(id,x,y+2,z+1);
        }
    }
    return 1;
}
So is it possible to make them to work faster?
Reply
#2

What is dUserInt supposed to do?
Reply
#3

Quote:
Originally Posted by Vince
What is dUserInt supposed to do?
DUDB - http://forum.sa-mp.com/index.php?topic=4798.0 .. if that's what you're asking for.
Reply
#4

Soooo.... Anybody wants to answer my question..?
Reply
#5

My sugestion is to get a rid of dini, and use ffile.
Reply
#6

Quote:
Originally Posted by [NL
WackoX ]
My sugestion is to get a rid of dini, and use ffile.
Is it faster? Or u just think it's better? And there are no ffile in these forums... :S
Reply
#7

When they login, save their login status. Then just check it to see if they are admin. This would save constantly checking the user file.

Код:
cmd_goto(playerid,params[]) // This command teleports me to player
{
	if (Admin[Playerid]>2)
	{
		// code
	}
	return 1;
}
Reply
#8

Quote:
Originally Posted by [LSD
Rac3r ]
When they login, save their login status. Then just check it to see if they are admin. This would save constantly checking the user file.

Код:
cmd_goto(playerid,params[]) // This command teleports me to player
{
	if (Admin[Playerid]>2)
	{
		// code
	}
	return 1;
}
OK, thanks.. I'll do that..
Any other optimization possibilities here?
Reply
#9

Honestly, I wouldn't worry. The command looks right, any optimisation would be very small and probably wouldn't effect any performance issues.

Take this as an example :
http://pastebin.com/m2d39cc17

If I changed your command, for my command... On our server we wouldn't notice any speed difference. Type the command, SA-MP does the command.
SA-MP is very quick at processing code, worrying too much about a few extra lines of code is not worth it IMO.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)