help me
#1

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

add:
PHP код:
PlayerName(playerid) {
  new 
pname[MAX_PLAYER_NAME];
  
GetPlayerName(playeridpnamesizeof(pname));
  return 
pname;

be sure you added it out of public and command too
Reply
#3

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

PHP код:
    if (strcmp(string"/setrank"true) == 0)
    {
        if (
orgleader[playerid] == 0)
            return 
SendClientMessage2(playeridCOLOR_WHITE"Error: You aren't the (co)leader of an organization.");
        new 
IDrank[28];
        
tmp strtok(cmdtextidx);
        if (!
strlen(tmp)) return SendClientMessage2(playeridCOLOR_WHITE"Usage: /setrank [playerid] [rank]");
        if (
strlen(rank) > 28) return SendClientMessage(playerid0xFF0000FF,"The maximum rank length is 28 characters!");
        if (!
IsPlayerConnected(ID)) return 1;
        if (
GetPVarInt(giveplayerid"playerorg") != GetPVarInt(playerid"playerorg"))
            return 
SendPlayerFormattedText(playeridCOLOR_RED"%s is not in your organization!"giveplayer"");
        
GetPlayerName(playeridplayernameMAX_PLAYER_NAME);
        
format(string,sizeof(string),"Your leader %s has given you a rank: '%d'"playernamerank);
        
SendClientMessage(ID0xFFFF00FFstring);
        
format(string,sizeof(string),"You have given a rank to %s (%d)"playernamerank);
        
SendClientMessage(playerid0xFFFF00FFstring);
        return 
1;
    } 
Reply
#5

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.
Reply
#6

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

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

:/ k thanks any way
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)