Simple Scripting
#1

Hello, I am relatively new to scripting and I've been playing around and trying new things to get this command to work but it seems a bit buggy. Code:
Код HTML:
CMD:dpm(playerid, text[])
	{
	new string[128];
	format(string, sizeof(string), "%s says: %s", text, text);
	SendClientMessage(playerid, COLOR_SAY, string);
		return 1;
	}
This is what happens:


I want it to be Message says: SecondMessage
Reply
#2

Are you using zcmd? Can you explain what the command is supposed to do exactly?
Is it that if I type "/dpm Hello!" all the other players see: "Schneider says: Hello!" ?

In that case:
pawn Код:
CMD:dpm(playerid, params[])
{
    new playername[MAX_PLAYER_NAME];
    new string[128];
    GetPlayerName(playerid, playername, sizeof(playername));
    format(string, sizeof(string), "%s says: %s", playername, params);
    SendClientMessageToAll(COLOR_SAY, string);
    return 1;
}
Reply
#3

And what is "SecondMessage"?
Currently you've set it to display the text you write in both strings.
pawn Код:
"%s says: %s", text, text);
I can try to explain, the above simply means:
"string1 says: string2", string1 = text, string2 = text (Text is set for both strings, and defined as what you write.)
Reply
#4

I want it to be like this:
/dpm Mynameisjoe Hisnameisjoe = Mynameisjoe says: Hisnameisjoe
It's kind of hard to explain but that's pretty much it.
Reply
#5

You need to create 2 different strings for that. And i would recommend using sscanf too.
pawn Код:
CMD:dpm(playerid, text[])
{
    new string[128], text1[64], text2[64];
    if(sscanf(params, "s[64]s[64]", text1, text2)) return SendClientMessage(playerid, -1, "USAGE: /dpm [text1] [text2]");
    format(string, sizeof(string), "%s says: %s", text1, text2);
    SendClientMessage(playerid, COLOR_SAY, string);
    return 1;
}
Reply
#6

sscanf crashes my server for some reason, I already tried using it and I have everything installed correctly.

Could you put it into regular form?
Reply
#7

Sorry, use this:
pawn Код:
if(sscanf(text, "s[64]s[64]", text1, text2)) return SendClientMessage(playerid, -1, "USAGE: /dpm [text1] [text2]");
Otherwise, are you sure this is correct, according to your command processor?:
pawn Код:
CMD:dpm(playerid, text[])
Reply
#8

Use sscanf2

pawn Код:
CMD:dpm(playerid, params[])
{
    new
        text[128];

    if(sscanf(params, "s", text))
        return SendClientMessage(playerid, 0xFFFFFFFF, "/dpm [Message]" );
       
    new
        Text1[128],
        name[MAX_PLAYER_NAME];

    GetPlayerName(playerid, name, sizeof(name));
    format(Text1, sizeof(Text1), "%s says: %s", name, text);
    SendClientMessageToAll( COLOR_SAY, Text1);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)