SA-MP Forums Archive
Nick problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Nick problem (/showthread.php?tid=504685)



Nick problem - Djumza - 05.04.2014

Hello guys, today i saw one little problem with my /slap command.. here it is:
pawn Код:
CMD:slap(playerid,params[])
{
    new id,msg[128],Float:x,Float:y,Float:z,name[MAX_PLAYER_NAME];
    if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid,COLOR_RED,"[SERVER]:You must be and Admin to use this command!");
    else if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"[SERVER]:Player is not connected anymore!");
    else if(sscanf(params,"u",id)) return SendClientMessage(playerid,COLOR_RED,"[SERVER]:Usage:/slap [name/id]");
    else
    {
        GetPlayerPos(id,x,y,z);
        SetPlayerPos(id,x,y,z+4);
        format(msg,sizeof(msg),"[SERVER]:You've been slapped by Admin %s!",GetPlayerName(playerid,name,sizeof(name)));
        SendClientMessage(id,COLOR_RED,msg);
    }
    return 1;
}
I guess here is a problem :
pawn Код:
format(msg,sizeof(msg),"[SERVER]:You've been slapped by Admin %s!",GetPlayerName(playerid,name,sizeof(name)));
        SendClientMessage(id,COLOR_RED,msg);
Because i get msg like : You've been slapped by Admin umza.ini! And my nick is Djumza...
Here is a picture :
Any ideas how to fix this ?


Re: Nick problem - MArkvane092 - 05.04.2014

Try this:

PHP код:
COMMAND:slap(playerid,params[])
{  
    new 
OtherPlayerMsg[150], Name[24], Message[150], OtherPlayerName[24];
    
SendAdminText(playerid,"/slap"params);
   
    if (
APlayerData[playerid][PlayerLevel] >= 2)
    {
        
GetPlayerName(playeridNamesizeof(Name));
        
GetPlayerName(OtherPlayerOtherPlayerNamesizeof(OtherPlayerName));
        
format(Msgsizeof(MSg), "%s Slaps %s because %s"NameOtherPlayerNameMessage);
        
SendClientMessageToAll(0xFFFFFFFFMsg);
        
SetPlayerHealth(OtherPlayer75);
    }
    else
    {
        return 
0;
    }
    return 
1;




Re: Nick problem - UfsDev - 05.04.2014

Use

Код:
dcmd_slap(playerid,params[]) {
    if(IsPlayerCommandLevel(playerid,"slap")) {
   		if(!strlen(params)) return SendClientMessage(playerid,red,"Syntax Error: \"/SLAP <NICK OR ID>\".");
   		new id; if(!IsNumeric(params)) id = ReturnPlayerID(params); else id = strval(params);
		if(IsPlayerConnected(id) && id != INVALID_PLAYER_ID && id != playerid) {
		    SendCommandMessageToAdmins(playerid,"SLAP");
		    new string[256],name[24],ActionName[24]; GetPlayerName(playerid,name,24); GetPlayerName(id,ActionName,24);
		    format(string,256,"Administrator \"%s\" has bitch-slapped \"%s\".",name,ActionName); SendClientMessageToAll(yellow,string);
			new Float:Health; GetPlayerHealth(id,Health); return SetPlayerHealth(id,Health-Config[SlapDecrement]);
		} else return SendClientMessage(playerid,red,"ERROR: You can not slap yourself or a disconnected player.");
	} else return SendLevelErrorMessage(playerid,"slap");
}



Re: Nick problem - Konstantinos - 05.04.2014

That's not the correct way of getting the name. Read the wiki: https://sampwiki.blast.hk/wiki/GetPlayerName

You get the name by storing it to an array and then using that array as argument.

pawn Код:
GetPlayerName(playerid,name,sizeof(name));
format(msg,sizeof(msg),"[SERVER]:You've been slapped by Admin %s!",name);
Quote:
Originally Posted by UfsDev
Посмотреть сообщение
Re-Compile Your FilterScripts If Its Admin System

Goto Server Folder >> pawno >> open pawno.exe then select filterscripts >> Compile it

if i helper you plz +REP
Please don't.. just don't! Posting things that are not going to fix his problems, just to get +1 post and say about some points..


Re: Nick problem - UfsDev - 05.04.2014

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
That's not the correct way of getting the name. Read the wiki: https://sampwiki.blast.hk/wiki/GetPlayerName

You get the name by storing it to an array and then using that array as argument.

pawn Код:
GetPlayerName(playerid,name,sizeof(name));
format(msg,sizeof(msg),"[SERVER]:You've been slapped by Admin %s!",name);


Please don't.. just don't! Posting things that are not going to fix his problems, just to get +1 post and say about some points..
I was think that he's saying that he cannot compile but when i saw picture then i UPDATE My Reply..


Re: Nick problem - Djumza - 05.04.2014

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
That's not the correct way of getting the name. Read the wiki: https://sampwiki.blast.hk/wiki/GetPlayerName

You get the name by storing it to an array and then using that array as argument.

pawn Код:
GetPlayerName(playerid,name,sizeof(name));
format(msg,sizeof(msg),"[SERVER]:You've been slapped by Admin %s!",name);


Please don't.. just don't! Posting things that are not going to fix his problems, just to get +1 post and say about some points..
Konstantinos you are my hero ! Thank you man ! You've earned reputation !