PDA

View Full Version : Giveplayerid


Trynda
09/05/2014, 05:02 AM
Hello, im really confused with this

I want the /givetoken

and it will increase the token value of player depends on token value i type

CMD:givetoken(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] == 6)
{
new giveplayerid;
new string[128];
if(sscanf(params, "ud", giveplayerid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givetoken [playerid/partofname] [token value]");

format
}
}

mrtms
09/05/2014, 05:10 AM
CMD:givetoken(playerid, params[])
{
new giveplayerid, token, string[128];
if(PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(sscanf(params, "ud", giveplayerid, token)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /givetoken [player] [amount]");

//This really depends on the variable you use to store the tokens
PlayerInfo[giveplayerid][pTokens] += token;

format(string, sizeof(string), "%s has given you %d token(s)!", GetPlayerName(playerid), token);
SendClientMessage(giveplayerid, COLOR_WHITE, string);
return 1;
}


I'm not to sure what you use to store the value of the token to the player, so I made up some random variable under the enum of PlayerInfo. Just replace the PlayerInfo[giveplayerid][pTokens], with the correct variable you use to store the amount of tokens a player has.

Trynda
09/05/2014, 05:17 AM
CMD:givetoken(playerid, params[])
{
new giveplayerid, token, string[128];
if(PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(sscanf(params, "ud", giveplayerid, token)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /givetoken [player] [amount]");

//This really depends on the variable you use to store the tokens
PlayerInfo[giveplayerid][pTokens] += token;

format(string, sizeof(string), "%s has given you %d token(s)!", GetPlayerName(playerid), token);
SendClientMessage(giveplayerid, COLOR_WHITE, string);
return 1;
}


I'm not to sure what you use to store the value of the token to the player, so I made up some random variable under the enum of PlayerInfo. Just replace the PlayerInfo[giveplayerid][pTokens], with the correct variable you use to store the amount of tokens a player has.

Thanks bro (+rep) But how about the /checktoken?

mrtms
09/05/2014, 05:22 AM
CMD:checktoken(playerid, params[])
{
new giveplayerid, string[128];
if(PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /checktoken [player]");

format(string, sizeof(string), "%s Tokens: %d", GetPlayerName(giveplayerid). PlayerInfo[giveplayerid][pToken]);
SendClientMessage(playerid, COLOR_WHITE, string);
return 1;
}

[..MonTaNa..]
09/05/2014, 05:23 AM
EDIT: too late :rolleyes: