string problem
#1

Код:
CMD:unfreeze(playerid, params[])
{
	new sendername[MAX_PLAYER_NAME], giveplayer[24], string[128];
	new para1;
	
	if(Player[playerid][pHelper] < 2 || Player[playerid][pAdmin] < 1)
	{
		SCM(pid, ADMIN_COLOR, ADMIN_MESSAGE);
		return 1;
	}
	
	GetPlayerName(playerid, sendername, sizeof(sendername));
	GetPlayerName(para1, giveplayer, sizeof(giveplayer));
	
	
	if(para1 == INVALID_PLAYER_ID)
	{
		SCM(pid, -1, "Player is not connected.");
		return 1;
	}
	
	if(sscanf(params, "u", para1))
	{
		SendClientMessage(playerid, COLOR_WHITE, "{00E6FF}USAGE:{FFFFFF} /freeze [PlayerID/PartOfName]");
		return 1;
	}
	
	TogglePlayerControllable(para1, 1);
	format(string, sizeof(string), " You have been unfrozen by admin {FF0000}%s", sendername);
	SCM(para1, COLOR_GREY, string);
	format(string, sizeof(string), "{D11515}[AdmWarning]: {FF9203}%s {FFFFFF}has unfrozen {FF9203}%s", sendername, giveplayer);
	SendA4Message(-1, string);
	format(string, sizeof(string), " You have unfrozen player {FF0000}%s", giveplayer);
	SCM(pid, COLOR_WHITE, string);
	return 1;
}
The problem is that when I /unfreeze a player the string will show the "sendername" name twice.
Example:
" [AdmWarning]: JXF has unfrozen JXF. "
Reply
#2

you have told the script to do that add another string with the reciver name
Reply
#3

Try This
PHP код:
new playerid,reason[64];
        if (
sscanf(params"dz"playeridreason))
        {
            return 
1;
        }
        if (
IsPlayerConnected(playerid))
        {
            new 
msg[128],name[MAX_PLAYER_NAME];
            
GetPlayerName(playeridnamesizeof(name));
            
format(msgsizeof(msg), "04*** %s has been unfrozen by %s on IRC."nameuser);
            
IRC_GroupSay(gGroupIDIRC_CHANNELmsg);
            
format(msgsizeof(msg), "* Admin %s on IRC has unfrozen %s ",username);
            
SendClientMessageToAll(0xAA3333AAmsg);
            
TogglePlayerControllable(playerid1);
        }
    }
    return 
1;

Or This
PHP код:
IRCCMD:unfreeze(botidchannel[], user[], host[], params[])
{
    if (
IRC_IsOp(botidchanneluser))
    {
        new 
playerid,reason[64];
        if (
sscanf(params"dz"playeridreason))
        {
            return 
1;
        }
        if (
IsPlayerConnected(playerid))
        {
            new 
msg[128],name[MAX_PLAYER_NAME];
            
GetPlayerName(playeridnamesizeof(name));
            
format(msgsizeof(msg), "04*** %s has been unfrozen by %s on IRC."nameuser);
            
IRC_GroupSay(gGroupIDIRC_CHANNELmsg);
            
format(msgsizeof(msg), "* Admin %s on IRC has unfrozen %s ",username);
            
SendClientMessageToAll(0xAA3333AAmsg);
            
TogglePlayerControllable(playerid1);
        }
    }
    return 
1;

Reply
#4

The problem is you're creating the variable 'para1', getting the name that para1 has, and then using sscanf.
So 'para1' will always be 0 before you use sscanf, so GetPlayerName(para1, ..) means GetPlayerName(0, ..)

Quote:
Originally Posted by CarRamper
Посмотреть сообщение
you have told the script to do that add another string with the reciver name
What?
Reply
#5

Quote:
Originally Posted by Stinged
Посмотреть сообщение
The problem is you're creating the variable 'para1', getting the name that para1 has, and then using sscanf.
So 'para1' will always be 0 before you use sscanf, so GetPlayerName(para1, ..) means GetPlayerName(0, ..)



What?
I see. Thank you. I got the name of para1 after using sscanf, thanks for the useful tip.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)