*** This topic title is not descriptive - ******
#1

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
Reply
#2

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);
Reply
#3

pawn Код:
format(string, sizeof(string), "You have %d money", PlayerInfo[playerid][pCash]);
Reply
#4

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?
Reply
#5

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;
}
Reply
#6

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

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
Reply
#8

i'm using the command as an example and btw i edited smh realize i made a tiny error
Reply
#9

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;
}
Reply
#10

are u serios ?
onplayerupdate gets called every 30ms or something
just use 1 globaltimer
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)