*** This topic title is not descriptive - ****** -
Zachlive - 08.11.2012
Hello, I am Zack and I have a few questions concerning a role play server that I am working on from scratch. (yes I am new, but I feel this will be the best way to learn ) I am trying to create a status command, but all my attempts have resulted in error, here is a example of my enum used
pawn Код:
enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pDeaths
}
How can I put this into a "SendClientMessage"?
Also how can I make it detect when I play goes into debt, and have it send them a message?
Thank you in advanced,
Zack
Re: Two quick questions. -
[HK]Ryder[AN] - 08.11.2012
after the enum you have to create something like this
pawn Код:
new PlayerInfo[MAX_PLAYERS][pInfo];
this will allow you to use all the anum variables
then in on player connect you can do you like this
pawn Код:
new string[100];
format(string, sizeof(string), "You have %s money", PlayerInfo[playerid][pCash]);
SendClientMessage(playerid, string);
Re: Two quick questions. -
Glad2BeHere - 08.11.2012
pawn Код:
format(string, sizeof(string), "You have %d money", PlayerInfo[playerid][pCash]);
Re: Two quick questions. -
Zachlive - 08.11.2012
Quote:
Originally Posted by [HK]Ryder[AN]
after the enum you have to create something like this
pawn Код:
new PlayerInfo[MAX_PLAYERS][pInfo];
this will allow you to use all the anum variables
then in on player connect you can do you like this
pawn Код:
new string[100]; format(string, sizeof(string), "You have %s money", PlayerInfo[playerid][pCash]); SendClientMessage(playerid, string);
|
Quote:
Originally Posted by Glad2BeHere
pawn Код:
format(string, sizeof(string), "You have %d money", PlayerInfo[playerid][pCash]);
|
Thank you so much, but how can I detect if a player is in debt?
Re: Two quick questions. -
[HK]Ryder[AN] - 08.11.2012
Outside a callback
pawn Код:
new alreadysentmessage[MAX_PLAYERS];
here it is(paste it in onplayerupdate only)
pawn Код:
if(PlayerInfo[playerid][pCash] < 0)
{
if(alreadysentmessage[playerid] == 0)
{
SendClientMessage(playerid, -1, "LAWL!!you are in debt :P");
for(new i=0;i<MAX_PLAYERS;i++;)
{
if(IsPlayerAdmin(i))
{
new string[100];
format(string, sizeof(string), "Player %d is in a debt of %d", playerid, PlayerInfo[playerid][pCash]);
SendClientMessage(i, -1, string);
}
}
}
alreadysentmessage[playerid] = 1;
return 1;
}
Re: Two quick questions. -
Glad2BeHere - 08.11.2012
pawn Код:
CMD:money(playerid,params[])
{
if(PlayerInfo[playerid][pCash] >=0)
{
format(string, sizeof(string), "You have %d money", PlayerInfo[playerid][pCash]);
}
else if(PlayerInfo[playerid][pCash] < 0)
{
format(string, sizeof(string), "You are in debt of %d ", PlayerInfo[playerid][pCash]);
}
SendClientMessage(playerid, -1, string);
return 1;
}
Re: Two quick questions. -
[HK]Ryder[AN] - 08.11.2012
Quote:
Originally Posted by Glad2BeHere
pawn Код:
CMD:money(playerid,params[]) { if(PlayerInfo[playerid][pCash] >=0) { format(string, sizeof(string), "You have %d money", PlayerInfo[playerid][pCash]); } else if(PlayerInfo[playerid][pCash] < 0) { format(string, sizeof(string), "You are in debt of %d ", PlayerInfo[playerid][pCash]); } SendClientMessage(playerid, -1, string); return 1; }
|
He doesn't want a command. He wants to keep checking if a player is in debt..
@Zachlive, editing my code to send the message to the rcon admin on the server too
Re: Two quick questions. -
Glad2BeHere - 08.11.2012
i'm using the command as an example and btw i edited smh realize i made a tiny error
Re: Two quick questions. -
[HK]Ryder[AN] - 08.11.2012
I edited my code too..
but i am posting it again too..
Outside a callback
pawn Код:
new alreadysentmessage[MAX_PLAYERS];
here it is(paste it in onplayerupdate only)
pawn Код:
if(PlayerInfo[playerid][pCash] < 0)
{
if(alreadysentmessage[playerid] == 0)
{
SendClientMessage(playerid, -1, "LAWL!!you are in debt :P");
for(new i=0;i<MAX_PLAYERS;i++;)
{
if(IsPlayerAdmin(i))
{
new string[100];
format(string, sizeof(string), "Player %d is in a debt of %d", playerid, PlayerInfo[playerid][pCash]);
SendClientMessage(i, -1, string);
}
}
}
alreadysentmessage[playerid] = 1;
return 1;
}
AW: Two quick questions. -
xerox8521 - 08.11.2012
are u serios ?
onplayerupdate gets called every 30ms or something
just use 1 globaltimer