ID 0 bug
#1

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
Reply
#2

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))
Reply
#3

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

Update your SSCANF! Inc and plugins
Reply
#5

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

download it, or else you will suffer from this bug
Reply
#7

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.
Reply
#8

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..
}
Reply
#9

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?
Reply
#10

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


Forum Jump:


Users browsing this thread: 2 Guest(s)