dcmd vs scanff vs strcmp ? -
gamer931215 - 16.08.2010
Hello guys, i am just one of the many beginners learning pawn, and getting better at it.
Now i created a few filterscripts/gamemodes etc but i am wondering..
What is the point of using scanff and/or dcmd except the faster speed i've readed.
I know there are tutorials for how to use it, but which one is the best and why ?
I think (hope atleast
) i am not the only beginner whos wondering about this.
Re: dcmd vs scanff vs strcmp ? -
Agent Smith - 16.08.2010
I've wonder about this as well. I made a thread but I didn't get any responce. Would be nice if someone could comment about it
Re: dcmd vs scanff vs strcmp ? -
gamer931215 - 16.08.2010
Quote:
Originally Posted by Samdudes
I've wonder about this as well. I made a thread but I didn't get any responce. Would be nice if someone could comment about it
|
Lets hope
Re: dcmd vs scanff vs strcmp ? -
vital2k - 16.08.2010
I use both zcmd and sscanf. Extremely easy to use and the speed is good.
They are used to cut down code mass as well as the speed of which they are processed.
Re: dcmd vs scanff vs strcmp ? -
gamer931215 - 16.08.2010
Quote:
Originally Posted by vital2k
I use both zcmd and sscanf. Extremely easy to use and the speed is good.
They are used to cut down code mass as well as the speed of which they are processed.
|
You mean like a PM command which requires /pm PLAYERID MESSAGE it can shorten the code instead of using a lot of extra functions like strtok etc in a strcmp command ?
Re: dcmd vs scanff vs strcmp ? -
Masj - 16.08.2010
dcmd is based on strcmp, just dcmd commands loads at the same time as GM. So... DCMD is not the best variant. Better ir ZCMD now, which uses CallLocalFunction. This function helps to hook function don't using strcmp in the onplayercommandtext. So ZCMD is the best variant for this time.
What's about sscanf. Sscanf is fast and very useful function. U can do the same with strtok but it's not comfortable... Much time u spend for arguments writting. So sscanf is the best way to explode strings.
Sscanf is very useful, because it has many features like integer, string, user, hex exploding.
Re: dcmd vs scanff vs strcmp ? -
gamer931215 - 16.08.2010
Quote:
Originally Posted by Masj
dcmd is based on strcmp, just dcmd commands loads at the same time as GM. So... DCMD is not the best variant. Better ir ZCMD now, which uses CallLocalFunction. This function helps to hook function don't using strcmp in the onplayercommandtext. So ZCMD is the best variant for this time.
What's about sscanf. Sscanf is fast and very useful function. U can do the same with strtok but it's not comfortable... Much time u spend for arguments writting. So sscanf is the best way to explode strings.
Sscanf is very useful, because it has many features like integer, string, user, hex exploding.
|
So basicly, sscanf is no command processor but for splitting arguments (like pm/kick/ban commands etc) and dcmd and zcmd are command compressors ?
Anyways i know now how dcmd (and zcmd too then i think) works, but cant find a good explaination about sscanf, do you know a simple tutorial :$ ? thanks for explaining anyways
Re: dcmd vs scanff vs strcmp ? - [L3th4l] - 16.08.2010
pawn Код:
CMD:kill(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return 0;
new ID;
if(sscanf(params, "u", ID)) return /*error message*/
/*Add filters, ifisplayerconnected, etc..*/
SetPlayerHealth(ID, 0.0);
return 1;
}
See how short they can be :P
Re: dcmd vs scanff vs strcmp ? -
gamer931215 - 16.08.2010
well thats a peace of script that kills you, i see
sscanf readed the given ID i guess, but why "u" and how to get multiple things like a personal message ?
Edit:
Thanks ******, im going to test these things soon and lets hope il get it to work
I thinks its easyer to understand once you used it a few times, and i think i know basicly how it works now
Re: dcmd vs scanff vs strcmp ? -
gamer931215 - 16.08.2010
Okay i get it now
pawn Код:
dcmd_pm(playerid,params[]) {
new id,message;
sscanf(params,"is",id,message);
new pName[32];
new string[128];
GetPlayerName(playerid,pName,32);
format(string,sizeof string,"PM From %s(%i): %s",pName,playerid,message);
SendClientMessage(id,COLOR_ORANGE,string);
}
return 1;
}
as example
Really usefull to know
, its like 3 times as small as my regular pm with strcmp