OnPlayerClickPlayer Help +Reps
#1

Hello, i want that onplayerclick to another player show his stats i got everything but i failed that when i click to another player it will show my stats
here is a normal cmd but i want it public OnPlayerClickPlayer(playerid, clickedplayerid, source)
CODE:
Код:
CMD:stats[/COLOR](playerid,params[])
{
	new string[500];
	new player1 = strval(params);
	if(sscanf(params,"u",player1))return SendClientMessage(playerid,Red,"[Usage]:- {FFFFFF}/stats [playerid]");
	if(IsPlayerConnected(player1))
	{
		format(string, sizeof(string), "{F31111}Name:- {FFFFFF}%s's Stats\n{F31111}Vip: {FFFFFF}%d\n{F31111}Kills: {FFFFFF}%d\n{F31111}Deaths: {FFFFFF}%d\n{F31111}Ratio: {FFFFFF}%0.2f\n{F31111}Money: {FFFFFF}$%d\n{F31111}Score: {FFFFFF}%d\n{F31111}FPS: {FFFFFF}%d", pName(player1),pInfo[player1][VLevel],pInfo[player1][Kills], pInfo[player1][Deaths], Float:pInfo[player1][Kills]/Float:pInfo[player1][Deaths],GetPlayerMoney(player1),GetPlayerScore(player1),GetPlayerFPS(player1));
		return ShowPlayerDialog(playerid,1235,DIALOG_STYLE_MSGBOX,"Player Stats!",string,"Ok","");
	}
	else return SendClientMessage(playerid, Red, "ERROR: Player Not Connected!");
}
sympol params error also :/
Reply
#2

Here is what I would do create a new function....

pawn Код:
ShowStats(playerid, player1)
{
    new string[500];
    format(string, sizeof(string), "{F31111}Name:- {FFFFFF}%s's Stats\n{F31111}Vip: {FFFFFF}%d\n{F31111}Kills: {FFFFFF}%d\n{F31111}Deaths: {FFFFFF}%d\n{F31111}Ratio: {FFFFFF}%0.2f\n{F31111}Money: {FFFFFF}$%d\n{F31111}Score: {FFFFFF}%d\n{F31111}FPS: {FFFFFF}%d", pName(player1),pInfo[player1][VLevel],pInfo[player1][Kills], pInfo[player1][Deaths], Float:pInfo[player1][Kills]/Float:pInfo[player1][Deaths],GetPlayerMoney(player1),GetPlayerScore(player1),GetPlayerFPS(player1));
    return ShowPlayerDialog(playerid,1235,DIALOG_STYLE_MSGBOX,"Player Stats!",string,"Ok","");
}
Then remove those lines in the stats command and replace with ShowStats(playerid, player1); then you can call the same function instead of trying to call your command it's self which makes more sense.

pawn Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source) ShowStats(playerid, clickedplayerid);
Reply
#3

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Here is what I would do create a new function....

pawn Код:
ShowStats(playerid, player1)
{
    new string[500];
    format(string, sizeof(string), "{F31111}Name:- {FFFFFF}%s's Stats\n{F31111}Vip: {FFFFFF}%d\n{F31111}Kills: {FFFFFF}%d\n{F31111}Deaths: {FFFFFF}%d\n{F31111}Ratio: {FFFFFF}%0.2f\n{F31111}Money: {FFFFFF}$%d\n{F31111}Score: {FFFFFF}%d\n{F31111}FPS: {FFFFFF}%d", pName(player1),pInfo[player1][VLevel],pInfo[player1][Kills], pInfo[player1][Deaths], Float:pInfo[player1][Kills]/Float:pInfo[player1][Deaths],GetPlayerMoney(player1),GetPlayerScore(player1),GetPlayerFPS(player1));
    return ShowPlayerDialog(playerid,1235,DIALOG_STYLE_MSGBOX,"Player Stats!",string,"Ok","");
}
Then remove those lines in the stats command and replace with ShowStats(playerid, player1); then you can call the same function instead of trying to call your command it's self which makes more sense.

pawn Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source) ShowStats(playerid, clickedplayerid);
Thanks alots bro ill try
Reply
#4

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Here is what I would do create a new function....

pawn Код:
ShowStats(playerid, player1)
{
    new string[320];
    format(string, sizeof(string), "{F31111}Name:- {FFFFFF}%s's Stats\n{F31111}Vip: {FFFFFF}%d\n{F31111}Kills: {FFFFFF}%d\n{F31111}Deaths: {FFFFFF}%d\n{F31111}Ratio: {FFFFFF}%0.2f\n{F31111}Money: {FFFFFF}$%d\n{F31111}Score: {FFFFFF}%d\n{F31111}FPS: {FFFFFF}%d", pName(player1),pInfo[player1][VLevel],pInfo[player1][Kills], pInfo[player1][Deaths], Float:pInfo[player1][Kills]/Float:pInfo[player1][Deaths],GetPlayerMoney(player1),GetPlayerScore(player1),GetPlayerFPS(player1));
    return ShowPlayerDialog(playerid, 1235, DIALOG_STYLE_MSGBOX, "Player Stats!", string, "Ok", "");
}
Then remove those lines in the stats command and replace with ShowStats(playerid, player1); then you can call the same function instead of trying to call your command it's self which makes more sense.

pawn Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source) ShowStats(playerid, clickedplayerid);
That will not work, a callback needs to be returned.
Also, this is not the best way to do for such a little piece of code.

Here you have the code for doing this with OnPlayerClickPlayer:
pawn Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    new string[320];
    format(string, sizeof(string), "{F31111}Name:- {FFFFFF}%s's Stats\n{F31111}Vip: {FFFFFF}%d\n{F31111}Kills: {FFFFFF}%d\n{F31111}Deaths: {FFFFFF}%d\n{F31111}Ratio: {FFFFFF}%0.2f\n{F31111}Money: {FFFFFF}$%d\n{F31111}Score: {FFFFFF}%d\n{F31111}FPS: {FFFFFF}%d", pName(clickedplayerid),pInfo[clickedplayerid][VLevel],pInfo[clickedplayerid][Kills], pInfo[clickedplayerid][Deaths], Float:pInfo[clickedplayerid][Kills]/Float:pInfo[clickedplayerid][Deaths],GetPlayerMoney(clickedplayerid),GetPlayerScore(clickedplayerid),GetPlayerFPS(clickedplayerid));
    return ShowPlayerDialog(playerid, 1235,DIALOG_STYLE_MSGBOX,"Player Stats!",string,"Ok","");
}
Reply
#5

Quote:
Originally Posted by BlackBank3
Посмотреть сообщение
That will not work, a callback needs to be returned.
Also, this is not the best way to do for such a little piece of code.

Here you have the code for doing this with OnPlayerClickPlayer:
pawn Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    new string[320];
    format(string, sizeof(string), "{F31111}Name:- {FFFFFF}%s's Stats\n{F31111}Vip: {FFFFFF}%d\n{F31111}Kills: {FFFFFF}%d\n{F31111}Deaths: {FFFFFF}%d\n{F31111}Ratio: {FFFFFF}%0.2f\n{F31111}Money: {FFFFFF}$%d\n{F31111}Score: {FFFFFF}%d\n{F31111}FPS: {FFFFFF}%d", pName(clickedplayerid),pInfo[clickedplayerid][VLevel],pInfo[clickedplayerid][Kills], pInfo[clickedplayerid][Deaths], Float:pInfo[clickedplayerid][Kills]/Float:pInfo[clickedplayerid][Deaths],GetPlayerMoney(clickedplayerid),GetPlayerScore(clickedplayerid),GetPlayerFPS(clickedplayerid));
    return ShowPlayerDialog(playerid, 1235,DIALOG_STYLE_MSGBOX,"Player Stats!",string,"Ok","");
}
This is Lux iv located it to my GM as TextDraw Can u locate it with my new admin system:
Код:
	new PlayerStatusBar[256];
	format(PlayerStatusBar,sizeof(PlayerStatusBar),"______________~G~Score: %d ~W~Ping: %d ~y~Weapon: %s ~P~State: %s ~y~~h~Last Killed By: %s ~b~~h~~b~Kills: %d ~R~Deaths: %d ~G~~h~Ratio: %0.2f",GetPlayerScore(playerid),GetPlayerPing(playerid),WeapName,State[playerid],WhoKilledYou[playerid],TotalKills[playerid],TotalDeaths[playerid],Float:TotalKills[playerid]/Float:TotalDeaths[playerid]);
	PlayerTextDrawSetString(playerid,PlayerStatus[playerid],PlayerStatusBar);
in new admin system functions are : pInfo[player1][Kills], pInfo[player1][Deaths]
Reply
#6

That callback does not need to be returned where did you get that idea? In fact only a few callbacks actually require some kind of return such as OnPlayerUpdate() or OnPlayerCommandText() if a function or callback has no return it automatically will return 0 try it yourself.

Run this code here http://slice-vps.nl:7070/

pawn Код:
#include <a_samp>


main() {
    printf("Return Value: %i", Test());

}

Test()
{
    new a;
    a += 10;
}
Output
Return Value: 0
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)