SA-MP Forums Archive
Script Help - 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: Script Help (/showthread.php?tid=394658)



Script Help - Zex Tan - 23.11.2012

Код:
CMD:pm(playerid, params[])
{
	new id, text[124];
	new string[124];
	new name=GetPlayerName(playerid);
	if(sscanf(params, "ui[124]", id, text))
	    return SendClientMessage(playerid, -1, "[USAGE]: /pm [playerid] [text]");
	format(string, sizeof(string), "((PM from %s:%s))", name, text);
	SendClientMessage(-1, string);
	return 1;
}
Errors:
Код:
E:\San Andreas Multiplayer Server Files (Classified)\Castaway Island Roleplay Server Files\gamemodes\CI-RP.pwn(225) : warning 202: number of arguments does not match definition
E:\San Andreas Multiplayer Server Files (Classified)\Castaway Island Roleplay Server Files\gamemodes\CI-RP.pwn(225) : warning 202: number of arguments does not match definition
E:\San Andreas Multiplayer Server Files (Classified)\Castaway Island Roleplay Server Files\gamemodes\CI-RP.pwn(229) : error 035: argument type mismatch (argument 2)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.



Re: Script Help - kaisersouse - 23.11.2012

Its the line before 'return 1;' at the end:

Should be
Код:
SendClientMessage(playerid,-1,string);



Re: Script Help - Zex Tan - 23.11.2012

Don't get it


Re: Script Help - Konstantinos - 23.11.2012

He means that you missed a parameter.
It's not
pawn Код:
SendClientMessage(-1,string);
but
pawn Код:
SendClientMessage(playerid,-1,string);



Re: Script Help - kaisersouse - 23.11.2012

You're missing "playerid" from your last SendClientMessage.


Re: Script Help - Ryox175 - 23.11.2012

Try this code. i hope it helped
pawn Код:
// PM Command
    if(strcmp("/pm", cmd, true) == 0)
    {
        tmp = strtok(cmdtext,idx);
       
        if(!strlen(tmp) || strlen(tmp) > 5) {
            SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /pm (id) (message)");
            return 1;
        }
       
        new id = strval(tmp);
        gMessage = strrest(cmdtext,idx);
       
        if(!strlen(gMessage)) {
            SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /pm (id) (message)");
            return 1;
        }
       
        if(!IsPlayerConnected(id)) {
            SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/pm : Bad player ID");
            return 1;
        }
       
        if(playerid != id) {
            GetPlayerName(id,iName,sizeof(iName));
            GetPlayerName(playerid,pName,sizeof(pName));
            format(Message,sizeof(Message),">> %s(%d): %s",iName,id,gMessage);
            SendClientMessage(playerid,PM_OUTGOING_COLOR,Message);
            format(Message,sizeof(Message),"** %s(%d): %s",pName,playerid,gMessage);
            SendClientMessage(id,PM_INCOMING_COLOR,Message);
            PlayerPlaySound(id,1085,0.0,0.0,0.0);
           
            printf("PM: %s",Message);
           
        }
        else {
            SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"You cannot PM yourself");
        }
        return 1;
    }



Re: Script Help - Zex Tan - 23.11.2012

Quote:
Originally Posted by kaisersouse
Посмотреть сообщение
You're missing "playerid" from your last SendClientMessage.
Still get errors ,
Код:
E:\San Andreas Multiplayer Server Files (Classified)\Castaway Island Roleplay Server Files\gamemodes\CI-RP.pwn(225) : warning 202: number of arguments does not match definition
E:\San Andreas Multiplayer Server Files (Classified)\Castaway Island Roleplay Server Files\gamemodes\CI-RP.pwn(225) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.



Re: Script Help - Ryox175 - 23.11.2012

try it as filterscript


Re: Script Help - YoYo123 - 23.11.2012

delete this:
pawn Код:
new name = GetPlayerName(playerid);
Instead do this:
pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof name);
https://sampwiki.blast.hk/wiki/GetPlayerName