Command issue [zcmd]
#1

Hi-

I have quite a few commands that don't give me issues, however if I return the sendername or target's name, it'll return player ID 0's name by default under the target name.
It's weird, can't really figure out what's wrong. Everything under the variables
new sendername[MAX_PLAYER_NAME]

and

GetPlayerName

is fine.

Any suggestions?
Reply
#2

Show us a command which is not working correctly.

If you do something like:
pawn Код:
new target, sendername[MAX_PLAYER_NAME];
GetPlayerName(target, sendername, sizeof(sendername));
That's will get the name of player with the ID 0 because you never assign the ID of the player you want into target.
Reply
#3

Код:
CMD:ainvite(playerid, params[])
{
	new faction, sendername[MAX_PLAYER_NAME], name[MAX_PLAYER_NAME], id, string[128];
	GetPlayerName(id, name, sizeof(name));
	GetPlayerName(playerid, sendername, sizeof(sendername));
	if(PlayerInfo[playerid][pAdmin] < 6) return SCM(playerid, GREY, NOADMIN);
	{
		if(sscanf(params,"ud", id, faction)) return SCM(playerid, COLOR_GREY, "Usage: /invite [playerid] [Faction ID]");
		{
	    	switch(faction)
	    	{
	    	    case 0:
	    	    {
			        PlayerInfo[id][pFaction] = 0;
		         	PlayerInfo[id][pRank] = 0;
			        format(string,sizeof(string),"{006600}[AdmCmd]{FFFFFF} You are now a civilian.");
			        SCM(id,COLOR_WHITE,string);
			        format(string,sizeof(string),"You made %s a civilian!", name);
		        	SCM(playerid,COLOR_YELLOW,string);
				}
				case 1:
				{
			        PlayerInfo[id][pFaction] = 1;
			        PlayerInfo[id][pRank] = 10;
			        format(string,sizeof(string),"{006600}[AdmCmd] {FFFFFF}You were added to the Sheriff's Department.");
			        SCM(id,COLOR_WHITE,string);
			        format(string,sizeof(string),"You invited %s to the Sheriff's Department!", name);
		        	SCM(playerid,COLOR_YELLOW,string);
				}
				case 2:
				{
				    PlayerInfo[id][pFaction] = 2;
				    PlayerInfo[id][pRank] = 9;
				    format(string,sizeof(string),"{006600}[AdmCmd]{FFFFFF} You were added to the Fire Department.");
				    SCM(id,COLOR_WHITE,string);
				    format(string,sizeof(string),"You invited %s to the Fire Department!", name);
		        	SCM(playerid,COLOR_YELLOW,string);
				}
				case 3:
				{
				    PlayerInfo[id][pFaction] = 3;
				    PlayerInfo[id][pRank] = 7;
				    format(string,sizeof(string),"{006600}[AdmCmd]{FFFFFF} You were added to the Medical Department.");
				    SCM(id,COLOR_WHITE,string);
				    format(string,sizeof(string),"You invited %s to the Medical Department!", name);
		        	SCM(playerid,COLOR_YELLOW,string);
				}
				case 4:
				{
				    PlayerInfo[id][pFaction] = 4;
				    PlayerInfo[id][pRank] = 7;
				    format(string,sizeof(string),"{006600}[AdmCmd]{FFFFFF} You were added to Red Line Racing.");
				    SCM(id,COLOR_WHITE,string);
				    format(string,sizeof(string),"You invited %s to Red Line Racing!", name);
		        	SCM(playerid,COLOR_YELLOW,string);
				}
				case 5:
				{
				    PlayerInfo[id][pFaction] = 5;
				    PlayerInfo[id][pRank] = 10;
				    format(string,sizeof(string),"{006600}[AdmCmd]{FFFFFF} You were added to the Department of Corrections.");
				    SCM(id,COLOR_WHITE,string);
				    format(string,sizeof(string),"You invited %s to DoC", name);
		        	SCM(playerid,COLOR_YELLOW,string);
				}
				case 6:
				{
				    PlayerInfo[id][pFaction] = 6;
				    PlayerInfo[id][pRank] = 12;
				    format(string,sizeof(string),"{006600}[AdmCmd]{FFFFFF} You were added to the Police Department.");
				    SCM(id,COLOR_WHITE,string);
				    format(string,sizeof(string),"You invited %s to LSPD", name);
		        	SCM(playerid,COLOR_YELLOW,string);
				}
				default:
				{
				    SCM(playerid, GREY, "Factions 1-6 only");
				    SCM(playerid, GREY, "[1 - Sheriff's | 2 - Fire | 3 - EMS | 4 - RRC | 5 - DoC | 6 - LSPD]");
				}
			}
		}
	}
 	return 1;
}
This is a good example of what happens-

The whole client message for this command is bugged. Kinda weird- only returns messages to ID 0.
Reply
#4

If it's bugged and it works only for playerid 0, then sscanf is an old version and you'll need to update plugin and include files. It happened to others many times before.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)