12.02.2017, 13:06
Ahoy
Currently i got 2 /get commands, the 1st one with strtok included, and the second one with sscanf.
I want to find out which one is faster and more efficient but i dont know if there is a way to measure that
I would be glad to receive help!
sscanf
strtok
Currently i got 2 /get commands, the 1st one with strtok included, and the second one with sscanf.
I want to find out which one is faster and more efficient but i dont know if there is a way to measure that
I would be glad to receive help!
sscanf
Код:
if(strcmp(cmd, "/get", true) == 0) { if(IsPlayerAdmin(playerid)) { new targetplayer; if(sscanf(cmdtext[strlen("/get")+1], "u", targetplayer)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /get [playerid]"); if(!IsPlayerConnected(targetplayer)) return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player not connected"); if(playerid == targetplayer) return SendClientMessage(playerid, COLOR_WHITE, "SERVER: You cannot get yourself!"); if(IsPlayerConnected(targetplayer)) { new Float:x, Float:y, Float:z; GetPlayerPos(playerid, x, y, z); SetPlayerInterior(targetplayer,GetPlayerInterior(playerid)); SetPlayerPos(targetplayer, x+1, y+1, z); return 1; } } else { return 0; } }
Код:
if(strcmp(cmd, "/get", true) == 0) { if(IsPlayerAdmin(playerid)) { new tmp[20], targetplayer; tmp = strtok(cmdtext, idx); if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /get [playerid]"); targetplayer = strval(tmp); if(!IsPlayerConnected(targetplayer)) return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player not connected"); if(playerid == targetplayer) return SendClientMessage(playerid, COLOR_WHITE, "SERVER: You cannot get yourself!"); if(IsPlayerConnected(targetplayer)) { new Float:x, Float:y, Float:z; GetPlayerPos(playerid, x, y, z); SetPlayerInterior(targetplayer,GetPlayerInterior(playerid)); SetPlayerPos(targetplayer, x+1, y+1, z); return 1; } } else { return 0; } }