Difference in speed between zcmd and strcmp
#1

I know that zcmd is faster than strcmp but the thing is.. i want to make my commands in strcmp and not zcmd because it's easier for me...
Is it a considerable speed difference between those two ? Will be the player affected somehow or the server ? ( Not RP script so it's not gonna have a super amount of commands )
Thanks.
Reply
#2

strcmp is really slow
the way strcmp works is that when you type a command it searches the script, if a match is found it executes the cmd.

zcmd calls a callback when command is typed..it is way faster.

see this graph (made by ******)
/imageshack/img195/43/fourcommands.png
Reply
#3

zcmd is good, but use sscanf two to make it even more easier.
i will show u and example
pawn Код:
COMMAND:sethp(playerid, params[])
{
if(sscanf(params,"ii",params[0],params[1])) return //return something if the player types it wrong
SetPlayerHealth(params[0],params[1]);
}
params[0] would be the playerid
parmas[1] would be the Amount of health
Reply
#4

Oh.. ok then
Thanks.
I guess i'm gonna use zcmd .
Reply
#5

Quote:
Originally Posted by park4bmx
Посмотреть сообщение
zcmd is good, but use sscanf two to make it even more easier.
i will show u and example
pawn Код:
COMMAND:sethp(playerid, params[])
{
if(sscanf(params,"ii",params[0],params[1])) return //return something if the player types it wrong
SetPlayerHealth(params[0],params[1]);
}
params[0] would be the playerid
parmas[1] would be the Amount of health
he is asking bout the speed..

OT - if you have a huge gamemode with 100+ commands you will notice lagg if using strcmp..
using zcmd its instant

and strcmp is case sensitive AFAIK
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
There is a case-insensitive parameter for strcmp.
:O..didnt know..you can remove this post
Reply
#7

he not only asked about the speed but he said "i want to make my commands in strcmp and not zcmd because it's easier for me..."
so I was think of the long method of using the strcmp and showed the method of sscanf becouse what else would be hard about strcmp9well yes there are other things).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)