help me -
mongi - 03.09.2015
what is the problem in this?
Код:
if (strcmp(string, "/setrank", true) == 0)
{
if (orgleader[playerid] == 0)
return SendClientMessage2(playerid, COLOR_WHITE, "Error: You aren't the (co)leader of an organization.");
new ID, rank[28];
tmp = strtok(cmdtext, idx);
if (!strlen(tmp)) return SendClientMessage2(playerid, COLOR_WHITE, "Usage: /setrank [playerid] [rank]");
if (strlen(rank) > 28) return SendClientMessage(playerid, 0xFF0000FF,"The maximum rank length is 28 characters!");
if (!IsPlayerConnected(ID)) return 1;
if (GetPVarInt(giveplayerid, "playerorg") != GetPVarInt(playerid, "playerorg"))
return SendPlayerFormattedText(playerid, COLOR_RED, "%s is not in your organization!", giveplayer, "");
new string[120];
format(string,sizeof(string),"Your leader %s has given you a rank: '%s'", PlayerName(playerid), rank);
SendClientMessage(ID, 0xFFFF00FF, string);
format(string,sizeof(string),"You have given a rank to %s (%s)", PlayerName(playerid), rank);
SendClientMessage(playerid, 0xFFFF00FF, string);
return 1;
}
and i get this warrings
Код:
C:\Users\Nidhal\Desktop\moi\server\gamemodes\bb_freeroam.pwn(15733) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Nidhal\Desktop\moi\server\gamemodes\bb_freeroam.pwn(15734) : error 017: undefined symbol "PlayerName"
C:\Users\Nidhal\Desktop\moi\server\gamemodes\bb_freeroam.pwn(15736) : error 017: undefined symbol "PlayerName"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
Re: help me -
jlalt - 03.09.2015
add:
PHP код:
PlayerName(playerid) {
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
return pname;
}
be sure you added it out of public and command too
Re: help me -
mongi - 03.09.2015
i fixed it but when i set a rank in game it say
Your leader Mongi has given you a rank: ''(here must be the rank)''
You have given a rank to Mongi ''(here must be the rank)''
the problem that i don't see the rank
this is the script
there are not any warrings
Код:
if (strcmp(string, "/setrank", true) == 0)
{
if (orgleader[playerid] == 0)
return SendClientMessage2(playerid, COLOR_WHITE, "Error: You aren't the (co)leader of an organization.");
new ID, rank[28];
tmp = strtok(cmdtext, idx);
if (!strlen(tmp)) return SendClientMessage2(playerid, COLOR_WHITE, "Usage: /setrank [playerid] [rank]");
if (strlen(rank) > 28) return SendClientMessage(playerid, 0xFF0000FF,"The maximum rank length is 28 characters!");
if (!IsPlayerConnected(ID)) return 1;
if (GetPVarInt(giveplayerid, "playerorg") != GetPVarInt(playerid, "playerorg"))
return SendPlayerFormattedText(playerid, COLOR_RED, "%s is not in your organization!", giveplayer, "");
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
format(string,sizeof(string),"Your leader %s has given you a rank: '%s'", playername, rank);
SendClientMessage(ID, 0xFFFF00FF, string);
format(string,sizeof(string),"You have given a rank to %s (%s)", playername, rank);
SendClientMessage(playerid, 0xFFFF00FF, string);
return 1;
}
Re: help me -
jlalt - 03.09.2015
PHP код:
if (strcmp(string, "/setrank", true) == 0)
{
if (orgleader[playerid] == 0)
return SendClientMessage2(playerid, COLOR_WHITE, "Error: You aren't the (co)leader of an organization.");
new ID, rank[28];
tmp = strtok(cmdtext, idx);
if (!strlen(tmp)) return SendClientMessage2(playerid, COLOR_WHITE, "Usage: /setrank [playerid] [rank]");
if (strlen(rank) > 28) return SendClientMessage(playerid, 0xFF0000FF,"The maximum rank length is 28 characters!");
if (!IsPlayerConnected(ID)) return 1;
if (GetPVarInt(giveplayerid, "playerorg") != GetPVarInt(playerid, "playerorg"))
return SendPlayerFormattedText(playerid, COLOR_RED, "%s is not in your organization!", giveplayer, "");
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
format(string,sizeof(string),"Your leader %s has given you a rank: '%d'", playername, rank);
SendClientMessage(ID, 0xFFFF00FF, string);
format(string,sizeof(string),"You have given a rank to %s (%d)", playername, rank);
SendClientMessage(playerid, 0xFFFF00FF, string);
return 1;
}
Re: help me -
Sjn - 03.09.2015
Do you realize that the "rank" var is a string and not an integer? And you can't use %d or %i (int specifier) for it. The format output gets bugged with some weird letters. Change
rank[28] to
rank
PS: I recommend you to use sscanf and zcmd cause this method is outdated already.
Re: help me -
mongi - 03.09.2015
i won't player id
[13:38:58] Your leader Mongi has given you a rank: '0'
[13:38:58] You have given a rank to Mongi (0)
i want the rank name
Re: help me -
Sjn - 03.09.2015
You need to create a rank system first, saving the rank in a file or however you are saving player's data. You can't directly use a string to get the rank name. Cause it will just show on your client message for example; saying that you gave "Private" rank to some players but the player won't get the rank, why? Cause you don't have the system built in, just a command.
Re: help me -
mongi - 03.09.2015
:/ k thanks any way