sscanf instead of strcmp?
#1

Ahoy friends.

Thats the command i have

Код:
if(strcmp(cmd, "/checkmoney", true) == 0)
	{
		if(IsPlayerAdmin(playerid))
		{
			new targetplayer;
			new tname[144];
			if(sscanf(cmdtext[strlen("/checkmoney")+1], "u", targetplayer))
			return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /checkmoney [playerid]");
			if(!IsPlayerConnected(targetplayer))
			return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player not connected");
			if(gPlayerHasTeamSelected[targetplayer] == -1)
			return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player is still in team selection!");
			GetPlayerName(targetplayer,tname,sizeof(tname));
			SendClientMessageEx(playerid,COLOR_WHITE,"SERVER: Player %s(%d) is in posession of $%d at this moment",tname,targetplayer,GetPlayerMoney(targetplayer));
		}	
	}
Is it possible to use sscanf instead of strcmp to check if the entered string matches?

Like

Код:
new targetplayer;
if(sscanf(cmdtext[strlen("/checkmoney")+1], "u", targetplayer))
	{
		if(IsPlayerAdmin(playerid))
		{
			new targetplayer;
			new tname[144];

			
			if(!IsPlayerConnected(targetplayer))
			return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player not connected");
			if(gPlayerHasTeamSelected[targetplayer] == -1)
			return SendClientMessage(playerid, COLOR_WHITE, "SERVER: Player is still in team selection!");
			GetPlayerName(targetplayer,tname,sizeof(tname));
			SendClientMessageEx(playerid,COLOR_WHITE,"SERVER: Player %s(%d) is in posession of $%d at this moment",tname,targetplayer,GetPlayerMoney(targetplayer));
		}	
	}
else
{
return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /checkmoney [playerid]");
}
Reply
#2

PHP код:
CMD:checkmoney(playerid,params[]){
    if(!
IsPlayerAdmin(playerid)) return 0;
    new 
targetplayer;
    if(
sscanf(params,"u",targetplayer)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /checkmoney [playerid]");
    
    new 
tname[MAX_PLAYER_NAME];
    if(!
IsPlayerConnected(targetplayer)) return SendClientMessage(playeridCOLOR_WHITE"SERVER: Player not connected");
    if(
gPlayerHasTeamSelected[targetplayer] == -1) return SendClientMessage(playeridCOLOR_WHITE"SERVER: Player is still in team selection!");
    
    
GetPlayerName(targetplayer,tname,sizeof(tname));
    
SendClientMessageEx(playerid,COLOR_WHITE,"SERVER: Player %s(%d) is in posession of $%d at this moment",tname,targetplayer,GetPlayerMoney(targetplayer));
    
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)