Enum question 3#! -
TheTerminator - 06.01.2015
Hello, yes, it's me again if you've seen my previous topics today!
I'll try and explain it briefly.
I'm thinking of making an inventory system, and I'm probably gonna use the enums for that.
Sort of like this:
pawn Код:
enum pInfo
{
pRation,
pMedKit
}
pawn Код:
CMD:giveration(playerid, params[])
{
if(PlayerInfo[playerid][pRation] >= 1) {
new PID;
new Playername1[MAX_PLAYER_NAME], Playername2[MAX_PLAYER_NAME];
GetPlayerName(playerid, Playername2, sizeof(Playername2));
GetPlayerName(PID, Playername, sizeof(Playername));
if(sscanf(params, "us[64]", PID)) return SendClientMessage(playerid, 0xFF0000FF, "[USAGE]: /giveration [PlayerID]");
if(!IsPlayerConnected(PID))
return SendClientMessage(playerid, -1, "Player is not connected!");
PlayerInfo[playerid][pRation]--;//decreases a point from rations in the .ini file, and basically says you gave away 1 ration
PlayerInfo[PID][pRation]++; // adds point to the other players rations.
}
else //if he has no rations
{
SendClientMessage(playerid, -1, "You don't have any rations to give away!");
}
return 1;
}
What I want to know is though, how do I make a dialog in which it shows the quantity of rations, to the person.
Basically, him doing a command like /inventory
and a dialogue would pop up, in which he could see
Rations ---- 1(or any number, depending how many of them he has)
Medkits ---- 5(or any number, depending how many of them he has)
I need it to somehow read the amount from the .ini file, and put it into the dialogue.
Do you guys think you can help? :/
Re: Enum question 3#! -
vassilis - 06.01.2015
You dont need anything the only think you need to do is when you pop up the dialog use a string %d (integer)
for example by using sendclientmessage
pawn Код:
new string[126];
format(string,sizeof(string),"Rations: %d",PlayerInfo[playerid][pRation]);
SendClientMessage(playerid,-1,string);
Re: Enum question 3#! -
TheTerminator - 06.01.2015
Could you tell me what %d (integer) means and what it does, so I can understand a bit better?
Re: Enum question 3#! -
Sid_Alexander - 06.01.2015
If you have a specific command like /inventory, Put this under the command
Modify the message myitem: and PlayerInfo[playerid][pItem] though.
pawn Код:
new string[200];
format(string, sizeof(string),"myitem: %d",PlayerInfo[playerid][pitem]);
ShowPlayerDialog(playerid, 1,DIALOG_STYLE_LIST,"Inventory",string,"Okay","Back");
Re: Enum question 3#! -
vassilis - 06.01.2015
%d = integer = means its for numbers for example
if a player has 1000 money
and i dothis
pawn Код:
new string[60];
format(string,sizeof(string),"Money: %d",PlayerInfo[playerid][Money]);
SendClientMessage(playerid,-1,string);
The out put will be
Money: 1000