[Tutorial] Making a simple PM system with ZCMD & sscanf
#21

not quite sure but try something like:
pawn Code:
if(str2 > 128)//gets if the players message is more then the max
{
    //rest of message here
}
Reply
#22

Can you making cmd /me with color purple?
Reply
#23

Quote:
Originally Posted by gondes
View Post
Can you making cmd /me with color purple?
pawn Code:
CMD:me(playerid, params[])
{
    new str[128], pName[24];
    GetPlayerName(playerid, pName, 24);
    if(sscanf(params, "s[128]", str))
    {
        return SendClientMessage(playerid, LBLUE, "Usage: /me (action)") &&
        SendClientMessage(playerid, ORANGE, "Function: make a me action");
    }
    format(str, sizeof(str), "* %s %s", pName, str);
    SendClientMessageToAll(PURPLE, str);
    return 1;
}
Reply
#24

You forgot to index the string in sscanf so this will flood your server with warnings.
Reply
#25

I have problem with this pm Scripts..
When i pm to id 0 - 5 its work Great, BUT, when i PM to id 6 - and bigger than id 6. the Message will Sent to id 0. anyone can help me ?
Reply
#26

Very nice
Reply
#27

Exellent Tutorial you just forgot

Quote:

if(playerid == id) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You cannot pm yourself!")

You forgot in the end of that line the ";"... Anyway Ty
Reply
#28

Good tut but you could have explained a bit more
But good tut.
Reply
#29

CMDm(playerid, params[])
{
new stringpm[128],toid, toname[128];
if(sscanf(params, "us", toid, params)) SendClientMessage(playerid, COLOR_ORANGE, "Correct usage: /pm <id> <message>");
else if(!IsPlayerConnected(toid)) SendClientMessage(playerid, COLOR_ORANGE, "ERROR: Player not connected");
if(playerid == toid) SendClientMessage(playerid, COLOR_ORANGE, "ERROR: You cannot send a PM to yourself!");
else
{
GetPlayerName(toid, toname, sizeof(toname));
format(stringpm, sizeof(stringpm), "PM To %s(%d): %s", playername, toid, params);
SendClientMessage(playerid, COLOR_YELLOW, stringpm);
format(stringpm, sizeof(stringpm), "PM From %s(%d): %s", playername, playerid, params);
SendClientMessage(toid, COLOR_YELLOW, stringpm);
}
return 1;
}



I did this but I keep getting error:

E:\My Server\gamemodes\SARCR.pwn(596) : error 029: invalid expression, assumed zero
E:\My Server\gamemodes\SARCR.pwn(596) : error 017: undefined symbol "cmd_pm"
E:\My Server\gamemodes\SARCR.pwn(596) : error 029: invalid expression, assumed zero
E:\My Server\gamemodes\SARCR.pwn(596) : fatal error 107: too many error messages on one line
Reply
#30

Have you got Zcmd?
Reply
#31

yes i downloaded it and copied it to pawno>inlude
Reply
#32

Do you have it inside your Gamemode/script?

pawn Code:
#include <Zcmd>
Reply
#33

yes, also below zcmd.inc in right side, there are no fuctions.
Reply
#34

rudy, plz help me
Reply
#35

when i covert it to dcmd, it the same error occurs
Reply
#36

Nice tut, very well explained
Reply
#37

Quote:
Originally Posted by M3ntaL
View Post
I got a problem

Did everything right, i gues, put the include
Code:
#include <zcmd>
and the code
Code:
CMD:es(playerid, params[])
{
    new str[256], str2[256], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
    if(sscanf(params, "us", id, str2))
    {
    	SendClientMessage(playerid, 0xFF0000FF, "Vihje: /es <id> <sхnum>");
  		return 1;
    }
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000FF, "VIGA: Player not connected");
    if(playerid != id) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You cannot pm yourself!");
    {
		GetPlayerName(playerid, Name1, sizeof(Name1));
 		GetPlayerName(id, Name2, sizeof(Name2));
        format(str, sizeof(str), "ES kasutajalt %s(ID %d): %s", Name2, id, str2);
        SendClientMessage(playerid, 0xFF0000FF, str);
        format(str, sizeof(str), "ES kasutajalt %s(ID %d): %s", Name1, playerid, str2);
        SendClientMessage(id, 0xFF0000FF, str);
    }
    return 1;
}
but i keep getting this error while i try to compile it ( just started scripting, i think i'm with good brain... just dont figure this out )

Code:
C:\Documents and Settings\Owner\Desktop\BBRP GM\gamemodes\bbrp.pwn(51) : error 017: undefined symbol "sscanf"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Btw. It's translated to Estonian, as you can see, dont mind that ^^.
You didn't included sscanf. At top of your script should be #include <sscanf2>, and of course you will need sscanf installed.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)