SetEventInfo weird bug
#1

Hey guys, I am having a little issue with my event system
Every options except of "Position" simply returns nothing
For example:
Input: /seteventinfo health 100
Output: nothing

Here is the code
PHP код:
CMD:seteventinfo(playeridparams[])
{
    if(!
IsAllowed(playerid3)) return NoAuth(playerid);
    new 
option[10];
    if(
sscanf(params"s[10]"option))
    {
        
SendClientMessage(playeridCOLOR_WHITE"UASGE: /seteventinfo [option]");
        
SendClientMessage(playeridCOLOR_GREY"Available Options: Health || Armour || Weapon || Position || Text");
        return 
1;
    }
    if(!
strcmp(option"position"true))
    {
        
GetPlayerPos(playeridEventPos[0], EventPos[1], EventPos[2]);
        
SendClientMessage(playeridCOLOR_LIGHTBLUE"You have set the event spawn-point at your position.");
        return 
1;
    }
    if(!
strcmp(option"health"true))
    {
        new 
Float:hp;
        if(
sscanf(params"s[10]f"optionhp)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /seteventinfo health [amount]");
        
EventHealth hp;
        
SendClientMessage(playeridCOLOR_LIGHTBLUE"You have set the new event health amount.");
        return 
1;
    }
    if(!
strcmp(option"armour"true))
    {
        new 
Float:ap;
        if(
sscanf(params"s[10]f"optionap)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /seteventinfo armour [amount]");
        
EventArmour ap;
        
SendClientMessage(playeridCOLOR_LIGHTBLUE"You have set the new event armour amount.");
        return 
1;
    }
    if(!
strcmp(option"weapon"true))
    {
        new 
slotweaponidammo;
        if(
sscanf(params"s[10]iii"optionslotweaponidammo)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /seteventinfo weapon [slot] [weapon] [ammo]");
        if(
slot || slot 3) return SendClientMessage(playeridCOLOR_GREY"Slots are between 1 to 3.");
        if(
GetWeaponSlot(weaponid) == -1) return SendClientMessage(playeridCOLOR_WHITE"Invalid weapon ID.");
        if(
ammo 1) return SendClientMessage(playeridCOLOR_GREY"Ammo must be 1 or higher.");
        new 
string[128], weaponname[32];
        
EventWeapon[slot--] = weaponid;
        
EventAmmo[slot--] = ammo;
        
GetWeaponName(weaponidweaponnamesizeof(weaponname));
        
format(stringsizeof(string), "You have set the %d event weapon slot to %s with %d bullets."slotweaponnameammo);
        
SendClientMessage(playeridCOLOR_LIGHTBLUEstring);
        return 
1;
    }
    if(!
strcmp(option"text"true))
    {
        new 
text[80];
        if(
sscanf(params"s[10]s[80]"optiontext)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /seteventinfo text [text]");
        
format(EventTextsizeof(EventText), "~r~%s"text);
        
SendClientMessage(playeridCOLOR_LIGHTBLUE"You have set the joining event game text.");
        return 
1;
    }
    return 
1;

Anyone ?
Reply
#2

Did you try changing the options order? For example, put "health" before "options".
Reply
#3

Quote:
Originally Posted by EnzoMetlc
Посмотреть сообщение
Did you try changing the options order? For example, put "health" before "options".
At first the "Available Options" was the last, and then the output for every option was the available options
Now it's simply nothing.
Reply
#4

Hmm, try something like this:

pawn Код:
if(sscanf(params[7], "f", hp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /seteventinfo health [amount]");
Where sscanf will start scan from the 7st index (you should to change it in every option).

Код:
health 100.0
^^^^^^^^
01234567...
Reply
#5

Quote:
Originally Posted by EnzoMetlc
Посмотреть сообщение
Hmm, try something like this:

pawn Код:
if(sscanf(params[7], "f", hp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /seteventinfo health [amount]");
Where sscanf will start scan from the 7st index (you should to change it in every option).

Код:
health 100.0
^^^^^^^^
01234567...
I am having a warning on the console
"sscanf warning: string buffer overflow"
Reply
#6

Anyone ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)