SA-MP Forums Archive
ID 0 bug - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: ID 0 bug (/showthread.php?tid=355818)



ID 0 bug - RedFusion - 01.07.2012

I converted my script from DCMD to ZCMD and now i've gotten this wierd bug, when i type a command like /Flip [ID] For example, and i leave the id field blank, it picks ID 0 automatically.
Код:
removed



Re: ID 0 bug - LaGrande - 01.07.2012

use sscanf instead of strlen..
i will give a quick example remove strlen(params)
and define player1 before this and add
pawn Код:
if (sscanf(params, "ud", player1))



Re: ID 0 bug - RedFusion - 01.07.2012

I have a ton of commands how do i replace them in the easiest way?


Re: ID 0 bug - Aprezt - 01.07.2012

Update your SSCANF! Inc and plugins


Re: ID 0 bug - RedFusion - 01.07.2012

Why would that help? I dont even have Sscanf yet.


Re: ID 0 bug - LaGrande - 01.07.2012

download it, or else you will suffer from this bug


Re: ID 0 bug - RedFusion - 01.07.2012

But why would i download it when i have STRLEN and i dont know how to convert?
I need to know how to convert to Sscanf, not a quick example, im not familiar with this.


Re: ID 0 bug - Slice - 01.07.2012

Because of a bug in CallLocalFunction, you can't pass empty strings. Therefore, ZCMD passes "\1" instead of an empty string.
A macro is provided to check if the params are empty:
pawn Код:
// WRONG:
is (!strlen(params)) {
    // no params..
}
// CORRECT:
is (isnull(params)) {
    // no params..
}
Alternatively, you could make a macro and add it on the top of all commands:
pawn Код:
#define NULL_PARAMS(); \
    if (!isnull(params)){}else{params[0]='\0';}

// Usage:
CMD:blabla(playerid, params[]) {
    NULL_PARAMS();

    // code..
}

CMD:blabla(playerid, params[]) {
    NULL_PARAMS();

    // code..
}

CMD:blabla(playerid, params[]) {
    NULL_PARAMS();

    // code..
}



Re: ID 0 bug - RedFusion - 01.07.2012

What if i have 3 parameters in a command, and the first 2 are critical, the third one fills up automatic if nothing is entered. For example: /Weapon <Playerid> <WeaponID/Name> <Ammo> Does that method work for this?


Re: ID 0 bug - Slice - 01.07.2012

"isnull" will only return true if the string is empty, i.e. no params. Everything else should work as it did before.