Unkown command as soon I use params!
#1

Now any command I script, doesn't work in my server!

I type /pstats, It says the error which I've scripted, but when I type /pstats (id) then it returns Server: Unkown Command!

Any idea why? Please help!
Reply
#2

show you script,
Reply
#3

pawn Код:
#define PATH "mainfs/%s.ini"

new Kills[MAX_PLAYERS], Deaths[MAX_PLAYERS], DerbyWon[MAX_PLAYERS], DuelWon[MAX_PLAYERS], DuelsAllow[MAX_PLAYERS];

stock UserPath(playerid)
{
    new file[40];
    format(file, sizeof(file), PATH, GetName(playerid));
    return file;
}

stock GetName(playerid)
{
    new Name[24];
    GetPlayerName(playerid, Name, sizeof(Name));
    return Name;
}

public OnPlayerConnect(playerid)
{
    new string[40];
    format(string, sizeof(string), "JLadmin/Users/%s.ini", GetName(playerid));
    if(fexist(string))
    {
        if(!fexist(UserPath(playerid)))
        {
            new INI:File = INI_Open(UserPath(playerid));
            INI_WriteInt(File, "Kills", 0);
            INI_WriteInt(File, "Deaths", 0);
            INI_WriteInt(File, "Derby Won", 0);
            INI_WriteInt(File, "DuelWon", 0);
            INI_WriteInt(File, "DuelsAllow", 0);
            INI_Close(File);
            SetTimerEx("SaveData", 1000, 1, "i", playerid);
        }
        else
        {
            INI_ParseFile(UserPath(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid);
        }
    }
}

stock SavePlayerData(playerid)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_WriteInt(File, "Kills", Kills[playerid]);
    INI_WriteInt(File, "Deaths", Deaths[playerid]);
    INI_WriteInt(File, "DerbyWon", DerbyWon[playerid]);
    INI_WriteInt(File, "DuelWon", DuelWon[playerid]);
    INI_WriteInt(File, "DuelsAllow", DuelsAllow[playerid]);
    INI_Close(File);
    return 1;
}

forward loadaccount_user(playerid, name[], value[]);
public loadaccount_user(playerid, name[], value[])
{
    INI_Int("Kills", Kills[playerid]);
    INI_Int("Deaths", Deaths[playerid]);
    INI_Int("Derby Won", DerbyWon[playerid]);
    INI_Int("DuelWon", DuelWon[playerid]);
    INI_Int("DuelsAllow", DuelsAllow[playerid]);
    return 1;
}

CMD:pstats(playerid, params[])
{
    new id;
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, -1,"{ff0000}Error: {ffffff}Correct usage: /stats (playerid)");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "{ff0000}Error: {ffffff}Player Is Not Connected");
    new string[201];
    format(string, sizeof(string), "{f7ea00}~~~~~~~~%s(%d)~~~~~~~ \n {ff0000}Kills: {00ff19}%d \n {ff0000}Deaths: {00ff19}%d \n {ff0000}Death Racing Won: {00ff19}%d \n {ff0000}Duels Won: {00ff19}%d \n {ff0000}Kill/Death Ratio: {00ff19}%d", GetName(id), id, Kills[id], Deaths[id], DerbyWon[id], DuelWon[id], Kills[id]/Deaths[id]);
    ShowPlayerDialog(playerid, 25, DIALOG_STYLE_MSGBOX, "{f7ea00}Player Statistics:", string, "Okay", "");
    return 1;
}
Reply
#4

The problem is more likely here:

pawn Код:
Kills[id]/Deaths[id]
Let's suppose the deaths are equal to 0, it might make your command return 0.

You should do this instead:

pawn Код:
floatdiv(Kills[id], Deaths[id])
In that case if the deaths are 0, it will return:
http://en.wikipedia.org/wiki/NaN

At least, it won't make your command return 0.
Reply
#5

Quote:
Originally Posted by ThePhenix
Посмотреть сообщение
The problem is more likely here:

pawn Код:
Kills[id]/Deaths[id]
Let's suppose the deaths are equal to 0, it might make your command return 0.

You should do this instead:

pawn Код:
floatdiv(Kills[id], Deaths[id])
THAAAAAAAAAAAAAAAAAAAAAAANKS AAAAAA LOOOOOOOOOT!

+rep'ed
Reply
#6

Be aware that, if the number of deaths are 0, it will return:
Код:
NaN
Here's an explanation for that:
http://en.wikipedia.org/wiki/NaN
Reply
#7

Quote:
Originally Posted by ThePhenix
Посмотреть сообщение
Be aware that, if the number of deaths are 0, it will return:
Код:
NaN
Here's an explanation for that:
http://en.wikipedia.org/wiki/NaN
ok np :P
for some reason, my deaths are 0 and it's returing -24242 something like that lol
Reply
#8

Use :
pawn Код:
if(sscanf(params, "i", id))
I Change u To i
Reply
#9

Quote:
Originally Posted by M0HAMMAD
Посмотреть сообщение
Use :
pawn Код:
if(sscanf(params, "i", id))
I Change u To i
He already got his answer, don't post if you don't know.
You should read sscanf2 documentation carefully.
Specifier "u" stands for players, so he's right.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)