Function "ShowStats" is not implemented -
Parrot - 13.01.2011
Hey. Okay so I am trying to make a /stats command. I found a good function in SAGC script and decided to use it in my script. Here is the error I get;
pawn Код:
myscript.pwn(267) : error 004: function "ShowStats" is not implemented
Here is my code;
At top of the script (above main()):
pawn Код:
forward ShowStats(playerid,targetid);
/stats commands:
pawn Код:
if(strcmp(cmd, "/stats", true) == 0)
{
ShowStats(playerid,playerid); [COLOR="Red"]This is the error line, 267.[/COLOR]
return 1;
}
The function at the bottom of the script:
pawn Код:
public ShowStats(playerid,targetid)
{
if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
{
if(gPlayerLogged[targetid])
{
SendClientMessage(playerid,COLOR_FUNNYGREEN,"STATS");
new wstring[128];
new score = PlayerInfo[targetid][pScore];
GetPlayerHealth(targetid,hp);
format(wstring, sizeof(wstring), "Level: %d | Hдlsa: %.1f",score, hp);
SendClientMessage(playerid,COLOR_WHITE, wstring);
}
}
}
Here is the code I remade into the above code, see if I forgot to add something to my code;
http://pastebin.com/cDBmeKPi
If there is anything else I must post in order to solve this, just tell and I will do it.
Thanks for reading! Please reply if you have a solution for this.
Re: Function "ShowStats" is not implemented -
zSuYaNw - 13.01.2011
try this;
pawn Код:
if(strcmp(cmd, "/stats", true) == 0)
{
if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
{
if(gPlayerLogged[targetid])
{
SendClientMessage(playerid,COLOR_FUNNYGREEN,"STATS");
new wstring[128];
new score = PlayerInfo[targetid][pScore];
GetPlayerHealth(targetid,hp);
format(wstring, sizeof(wstring), "Level: %d | Hдlsa: %.1f",score, hp);
SendClientMessage(playerid,COLOR_WHITE, wstring);
}
}
return 1;
}
edit
Or
pawn Код:
if(strcmp(cmd, "/stats", true) == 0)
{
if(IsPlayerConnected(playerid)&&IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid])
{
SendClientMessage(playerid,COLOR_FUNNYGREEN,"STATS");
new wstring[128];
new score = PlayerInfo[playerid][pScore];
GetPlayerHealth(playerid,hp);
format(wstring, sizeof(wstring), "Level: %d | Hдlsa: %.1f",score, hp);
SendClientMessage(playerid,COLOR_WHITE, wstring);
}
}
return 1;
}
Re: Function "ShowStats" is not implemented -
Parrot - 13.01.2011
Thought for a moment that was the mistake I made, but when I tried what you wrote the same error occured on the same line.
EDIT: Testing the new code you made.
EDIT2: I shouldn't need to write all that code again seeing as it's in the function below.
pawn Код:
The errors I got were;
267) : error 017: undefined symbol "targetid"
.pwn(269) : error 017: undefined symbol "targetid"
.pwn(274) : error 017: undefined symbol "targetid"
.pwn(275) : error 017: undefined symbol "targetid"
.pwn(277) : error 017: undefined symbol "hp"
.pwn(278) : error 017: undefined symbol "COLOR_WHITE" // I know it's just because a color isn't defined.. still a lot of errors.
Re: Function "ShowStats" is not implemented -
Scenario - 13.01.2011
Quote:
Originally Posted by [Full]Garfield[XDB]
try this;
pawn Код:
if(strcmp(cmd, "/stats", true) == 0) { ShowStats(playerid, targetid); return 1; }
|
You don't know anything about coding, do you? I don't know if you can put the forwards above the "main() {}"; try putting the forward line above the public line for the function. If that doesn't do anything, try making it a stock.
Re: Function "ShowStats" is not implemented -
zSuYaNw - 13.01.2011
Quote:
Originally Posted by RealCop228
You don't know anything about coding, do you? I don't know if you can put the forwards above the "main() {}"; try putting the forward line above the public line for the function. If that doesn't do anything, try making it a stock.
|
More time don't developer scripts,
sorry

Re: Function "ShowStats" is not implemented -
Parrot - 13.01.2011
I do know a bit about coding. The forward should be able to be in the top.
EDIT: Put the forward above the function. Didn't matter, same error. Can you do me the favour to give me the strock code? I will obviously try making my own, but just incase I fail, you diggin? If anyone got a similar code to what I am making and would be happy to share it I would really appreciate it.
Re: Function "ShowStats" is not implemented -
Scenario - 13.01.2011
Quote:
Originally Posted by Parrot
I do know a bit about coding. The forward should be able to be in the top.
|
I wasn't referring to you...
Quote:
Originally Posted by Parrot
EDIT: Put the forward above the function. Didn't matter, same error. Can you do me the favour to give me the strock code? I will obviously try making my own, but just incase I fail, you diggin? If anyone got a similar code to what I am making and would be happy to share it I would really appreciate it.
|
It's simple... With a stock function, you don't need to "forward" it; so remove the forward line. Replace "public" with "stock" and then you are all good to go. See if that does anything for you.
Re: Function "ShowStats" is not implemented -
Parrot - 13.01.2011
Didn't work, same error. Maybe this code just don't work for my script? It sounds odd but what could it be.
Re: Function "ShowStats" is not implemented -
Scenario - 13.01.2011
I see the problem. You aren't returning anything. You need to add "return 1;" to the function.
Re: Function "ShowStats" is not implemented -
Parrot - 14.01.2011
Feels like I've been trying to put return 1; everywhere in the function and still no success..
Below I will show where in the script I have tried putting return.
pawn Код:
public ShowStats(playerid,targetid)
{
if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
{
if(gPlayerLogged[targetid])
{
SendClientMessage(playerid,COLOR_FUNNYGREEN,"STATS");
new wstring[128];
new score = PlayerInfo[targetid][pScore];
GetPlayerHealth(targetid,hp);
format(wstring, sizeof(wstring), "Level: %d | Hдlsa: %.1f",score, hp);
SendClientMessage(playerid,COLOR_WHITE, wstring);
//HERE I TRIED RETURN
}
//HERE I TRIED RETURN
}
//HERE I TRIED RETURN
}
If you look at Raven's roleplay/SAGC script you see their functions don't return anything.
I really need a fix for this, and RealCop, I appreciate your help so far lets see if someone can help me get this working, thanks.