SA-MP Forums Archive
Unkown command as soon I use params! - 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: Unkown command as soon I use params! (/showthread.php?tid=534621)



Unkown command as soon I use params! - PMH - 30.08.2014

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!


Re: Unkown command as soon I use params! - kloning1 - 30.08.2014

show you script,


Re: Unkown command as soon I use params! - PMH - 30.08.2014

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;
}



Re: Unkown command as soon I use params! - ThePhenix - 30.08.2014

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.


Re: Unkown command as soon I use params! - PMH - 30.08.2014

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


Re: Unkown command as soon I use params! - ThePhenix - 30.08.2014

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


Re: Unkown command as soon I use params! - PMH - 30.08.2014

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


Re: Unkown command as soon I use params! - M0HAMMAD - 30.08.2014

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


Re: Unkown command as soon I use params! - ThePhenix - 30.08.2014

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.