/amessage not working
#1

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.
Reply
#2

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.
Reply
#3

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
Reply
#4

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];
Reply
#5

None of them worked.

I just get:



Uploaded with ImageShack.us
Reply
#6

EDIT: Double Posted.
Reply
#7

ok but you're not telling estring to equal params
Reply
#8

re-read my post above
Reply
#9

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

@cessil;

%s",string);

Speaks for it's self.
Reply
#10

Then post the goddamn errors
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)