SA-MP Forums Archive
/amessage not working - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /amessage not working (/showthread.php?tid=175101)



/amessage not working - [UG]Scripter - 08.09.2010

I have a problem with my A message Code;

pawn Код:
dcmd_amessage(playerid,params[])
{
    new id, n[MAX_PLAYER_NAME];
    new string[256];
    new estring[255];
    if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid,ORANGE,"You need to be level 3 to use this command!");
    if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /amessage <ID> <Messsage>");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,GREY,"Invalid ID");
    format(string,sizeof(string),"(INFO): Message from Server Administration: %s ",estring);
    SendClientMessage(playerid,YELLOW,estring);
    return 1;
}

Should allow the admin to type a meesage and send it to the player. This code just shows a space and nothing I told it to.

I had code before where it said " (INFO) Message from Server Administration" but that didnt show what the admin typed. Any ideas as to why it's not working.


Bear in mind I dont know how to fully use DCMD.


Re: /amessage not working - LarzI - 08.09.2010

Use sscanf:

pawn Код:
dcmd_amessage(playerid,params[])
{
    new id, n[MAX_PLAYER_NAME];
    new string[128];
    if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid,ORANGE,"You need to be level 3 to use this command!");
    if(sscanf(params, "us", id, string)
        return SendClientMessage(playerid,GREY,"USAGE: /amessage <ID> <Messsage>");
    if(!IsPlayerConnected(id))
        return SendClientMessage(playerid,GREY,"Invalid ID");
    format(string,sizeof(string),"(INFO): Message from Server Administration: %s ", string);
    SendClientMessage(id,YELLOW,string);
    return 1;
}
EDIT: I put "ui" instead of "us" sorry.
The code above should and will work.


Re: /amessage not working - cessil - 08.09.2010

pawn Код:
format(string,sizeof(string),"(INFO): Message from Server Administration: %s ",estring);
    SendClientMessage(playerid,YELLOW,estring);
you're formatting string but sending estring, also note that the max length of a player message in sa-mp is 128 not 256


Re: /amessage not working - R@ger - 08.09.2010

why use 2 strings which will wast so much of memory optimize script for better performance.

https://sampforum.blast.hk/showthread.php?tid=55261

new string[256];
new estring[255];


Re: /amessage not working - [UG]Scripter - 08.09.2010

None of them worked.

I just get:



Uploaded with ImageShack.us


Re: /amessage not working - [UG]Scripter - 08.09.2010

EDIT: Double Posted.


Re: /amessage not working - cessil - 08.09.2010

ok but you're not telling estring to equal params


Re: /amessage not working - LarzI - 08.09.2010

re-read my post above


Re: /amessage not working - [UG]Scripter - 08.09.2010

Your code doesn't work on my Admin System. I get like 5 errors.

@cessil;

%s",string);

Speaks for it's self.


Re: /amessage not working - LarzI - 08.09.2010

Then post the goddamn errors