OnPlayerClickPlayer gives error
#1

pawn Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    new id;
    new Cash = PlayerInfo[id][pCash];
    new Deaths = PlayerInfo[id][pDeaths];
    new Kills = PlayerInfo[id][pKills];
    new Score = PlayerInfo[id][pScore];
    new pName[24];
    new string[128];
    new Rank[30];
    id = clickedplayerid;

    switch(Kills)
    {
        case 0..100: Rank = "Newbie";
        case 101..200: Rank = "Playa";
        case 201..300: Rank = "Gangsta";
        case 301..400: Rank = "Homie";
        case 401..500: Rank = "Respected Killer";
        case 501..600: Rank = "Killing Machine";
        case 601..700: Rank = "Jacker";
        case 701..800: Rank = "Marvellous Killer";
        case 801..900: Rank = "Criminal";
        case 901..1000: Rank = "GodFather";
        case 1001..2000: Rank = "The fucking god";
    }

    if(sscanf(params, "u", id))
        return SendClientMessage(playerid, DEEPPINK, "USAGE: /stats <id>");

    if(!IsPlayerConnected(id))
        return SendClientMessage(playerid, DEEPPINK, "ERROR: Player is not connected.");
    {
        GetPlayerName(playerid, pName, sizeof pName);
        format(string, sizeof(string), "{00FF22}[Stats of {FFFFFF}%s{00FF22}]", pName);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "{FFFFFF}Cash: {00FF22}%d $ | {FFFFFF}Rank: {00FF22}%s", Cash , Rank);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "{FFFFFF}Deaths: {00FF22}%d {FFFFFF}| Kills: {00FF22}%d", Deaths, Kills);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "{FFFFFF}Score: {00FF22}%d", Score);
        SendClientMessage(playerid, -1, string);
    }
    return 1;
}
So my error is ..

Код:
C:\Users\user7\Desktop\extensionss\Server\gamemodes\new.pwn(308) : error 017: undefined symbol "params"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
please help
Reply
#2

Please, what is the 308 lines?
Reply
#3

This is not an sscanf function man. This is a callback. Code lines
pawn Код:
if(sscanf(params, "u", id))
        return SendClientMessage(playerid, DEEPPINK, "USAGE: /stats <id>");

    if(!IsPlayerConnected(id))
        return SendClientMessage(playerid, DEEPPINK, "ERROR: Player is not connected.");
are useless. How is it possible to click on a player on score board while he is disconnected? And there is no input so why to use sscanf?

This is your whole callback:
pawn Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    new id;
    new Cash = PlayerInfo[id][pCash];
    new Deaths = PlayerInfo[id][pDeaths];
    new Kills = PlayerInfo[id][pKills];
    new Score = PlayerInfo[id][pScore];
    new pName[24];
    new string[128];
    new Rank[30];
    switch(Kills)
    {
        case 0..100: Rank = "Newbie";
        case 101..200: Rank = "Playa";
        case 201..300: Rank = "Gangsta";
        case 301..400: Rank = "Homie";
        case 401..500: Rank = "Respected Killer";
        case 501..600: Rank = "Killing Machine";
        case 601..700: Rank = "Jacker";
        case 701..800: Rank = "Marvellous Killer";
        case 801..900: Rank = "Criminal";
        case 901..1000: Rank = "GodFather";
        case 1001..2000: Rank = "The fucking god";
    }
        GetPlayerName(clickedplayerid, pName, sizeof(pName));
        format(string, sizeof(string), "{00FF22}[Stats of {FFFFFF}%s{00FF22}]", pName);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "{FFFFFF}Cash: {00FF22}%d $ | {FFFFFF}Rank: {00FF22}%s", Cash , Rank);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "{FFFFFF}Deaths: {00FF22}%d {FFFFFF}| Kills: {00FF22}%d", Deaths, Kills);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "{FFFFFF}Score: {00FF22}%d", Score);
        SendClientMessage(playerid, -1, string);
    }
    return 1;
}
Reply
#4

308 line - if(sscanf(params, "u", id))
Reply
#5

Quote:
Originally Posted by MiGu3X
Посмотреть сообщение
308 line - if(sscanf(params, "u", id))
Are you oblivious to everything posted above? You're calling on params in a callback (which, as mentioned before does not have any).

As for fixing your problem, simply use if(IsPlayerConnected(playerid)) instead of the line above. You did it right when checking if the player was disconnected. I'm guessing this code is not yours.
Reply
#6

here are some (more) suggestions to optimize a little:
pawn Код:
new id;
    new Cash = PlayerInfo[id][pCash];
    //....
    id = clickedplayerid;
the Cash variable will store the playerid 0's cash, since
pawn Код:
id = clickedplayerid;
gets assigned after Cash, Deaths, Kills, Score got assigned their values. indeed that will give you playerid 0's stats always. this
pawn Код:
new id= clickedplayerid;//id gets assigned the clicked player...
    new Cash = PlayerInfo[id][pCash];//and here the id gets used already.
    new Deaths = PlayerInfo[id][pDeaths];
    new Kills = PlayerInfo[id][pKills];
    new Score = PlayerInfo[id][pScore];
    new pName[24];
    new string[128];
    new Rank[30];
//    id = clickedplayerid;//delete that line - its redundant now.
is better already, but creating the id variable has no sense - its a duplicate of clickedplayerid. use it instead of id.
pawn Код:
new Cash = PlayerInfo[clickedplayerid][pCash];//no id needed.
    new Deaths = PlayerInfo[clickedplayerid][pDeaths];
    new Kills = PlayerInfo[clickedplayerid][pKills];
    new Score = PlayerInfo[clickedplayerid][pScore];
    new pName[24];
    new string[128];
    new Rank[30];
...it seems you wanted to convert a command into the callback

concerning the switch/case conditions: those can be memory consuming, if the ranges are broad. not that 2000 max cases are really much, but by reducing it to 1/100 it will run faster:
pawn Код:
switch(Kills/100)
    {
        case 0: Rank = "Newbie";
        case 1: Rank = "Playa";
        //....
        case 9: Rank = "GodFather";
        case 10..19: Rank = "The fucking god";
        default: Rank = "cheater with >=2000 kills? nah. add some ranks!";//not that this happens, but who knows...
after considering the other tips, your callback could be summarized:
pawn Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    new Cash = PlayerInfo[clickedplayerid][pCash];
    new Deaths = PlayerInfo[clickedplayerid][pDeaths];
    new Kills = PlayerInfo[clickedplayerid][pKills];
    new Score = PlayerInfo[clickedplayerid][pScore];
    new pName[24];
    new string[128];
    new Rank[30];

    switch(Kills/100)
    {
        case 0: Rank = "Newbie";
        case 1: Rank = "Playa";
        case 2: Rank = "Gangsta";
        case 3: Rank = "Homie";
        case 4: Rank = "Respected Killer";
        case 5: Rank = "Killing Machine";
        case 6: Rank = "Jacker";
        case 7: Rank = "Marvellous Killer";
        case 8: Rank = "Criminal";
        case 9: Rank = "GodFather";
        case 10..19: Rank = "The fucking god";
        default: Rank = "cheater with >=2000 kills? nah. add some ranks!";
    }

    GetPlayerName(clickedplayerid, pName, sizeof pName);
    format(string, sizeof(string), "{00FF22}[Stats of {FFFFFF}%s{00FF22}]", pName);
    SendClientMessage(playerid, -1, string);
    format(string, sizeof(string), "{FFFFFF}Cash: {00FF22}%d $ | {FFFFFF}Rank: {00FF22}%s", Cash , Rank);
    SendClientMessage(playerid, -1, string);
    format(string, sizeof(string), "{FFFFFF}Deaths: {00FF22}%d {FFFFFF}| Kills: {00FF22}%d", Deaths, Kills);
    SendClientMessage(playerid, -1, string);
    format(string, sizeof(string), "{FFFFFF}Score: {00FF22}%d", Score);
    SendClientMessage(playerid, -1, string);
    return 1;
}
..and you forgot to use clickedplayerid in the GetPlayerName(). did i miss anything?
not tested (as usual).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)