how to make /pm [STRCMP]
#1

Could someone help me make one:L
Reply
#2

fuck string compare, too slow 'n old fashioned :P

use YCMD, here:
PHP код:
//the macro
new str8hgn86[256];
#define SFM(%0,%1,%2,%3) format(str8hgn86, sizeof(str8hgn86),%2,%3) && SendClientMessage(%0, %1, str8hgn86)
//the function
stock GetName(playerid)
{
    new 
n[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnMAX_PLAYER_NAME);
    return 
n;
}
//the cmd
YCMD:pm(playeridparams[], help)
{
    if(
help) return SendClientMessage(playerid,gray,"/pm is used to send private messages");
    new 
i;
    if(
sscanf(params,"ds[150]",i,params)) return SendClientMessage(playerid,red,"USAGE: /pm [ID] [MSG]");
    if(!
IsPlayerConnected(i)) return SendClientMessage(playerid,red,"That ID doesn't exist.");
    
SFM(playerid,yellow,"TO %s:{FFFFFF} %s",GetName(i),params);
    
SFM(i,orange,"FROM %s: {FFFFFF}%s",GetName(playerid),params);
    return 
1;






but if you still wanna have it your way,
i got something from an rly old script
and i really don't recommend using it

PHP код:
new cmd[256];
new    
tmp[256];
new 
gMessage[256];
new 
pName[MAX_PLAYER_NAME+1];
new 
iName[MAX_PLAYER_NAME+1];
new    
idx;
cmd strtok(cmdtextidx);
if(
strcmp("/pm"cmdtrue) == 0)
{
    
tmp strtok(cmdtext,idx);
    if(!
strlen(tmp) || strlen(tmp) > 5) {
        
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"TIPP: /pm (ID) (Text)");
        return 
1;
    }
    new 
id strval(tmp);
    
gMessage strrest(cmdtext,idx);
    if(!
strlen(gMessage)) {
        
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"TIPP: /pm (ID) (Text)");
        return 
1;
    }
    if(!
IsPlayerConnected(id)) {
        
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/pm : Diese ID exestiert nicht");
        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);
    }
    else {
        
SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Du kannst keine PM an dich selbst senden xD");
    }
    return 
1;

see how big 'n shitty it looks?
switch to YCMD mate!
Reply
#3

use ZCMD, more flexyable.

Код:
#include zcmd

-------


CMD:pm(playerid, params[]) 
{
    new id, message[1024];
    if(sscanf(params,"ds[1024]",id,message))return SendClientMessage(playerid, COLOR_RED, ""COL_RED"[ERROR]: "COL_WHITE"Usage: /pm <playerid> <message>");
    if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, ""COL_RED"[ERROR]: "COL_WHITE"Player is not connected.");
    if(playerid != id) {
        new PlayerName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
        new ReturnName[MAX_PLAYER_NAME];
        new szString[128];
        GetPlayerName(id, ReturnName, sizeof(ReturnName));
        format(szString,sizeof(szString), ">> PM To %s (ID:%d): %s", ReturnName, id, message);
        SendClientMessage(playerid, COLOR_YELLOW, szString);
        format(szString,sizeof(szString),"<< PM From %s (ID:%d): %s",PlayerName, playerid, message);
        SendClientMessage(id, COLOR_YELLOW, szString);
        PlayerPlaySound(id, 1085, 0.0, 0.0, 0.0);
    }
    else {
        SendClientMessage(playerid, COLOR_RED, "ERROR: You cannot PM yourself");
    }
    return 1;
}
Reply
#4

Or use my solution :

Код:
new _cmdtext[50], params[200];
	
sscanf(cmdtext, "s[50]s[200]" , _cmdtext, params);


	if (strcmp("/pm", _cmdtext, true) == 0)
	{
		new idp, playerName[MAX_PLAYER_NAME], texte[220], string[255];
			
		if(sscanf(params, "is[220]", idp, texte)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /pm [idjoueur] [texte]");
		
		GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
		format(string, sizeof(string), "%s[%i]: ((%s))", playerName, playerid, texte);
		
		if(IsPlayerConnected(idp)) {
			SendClientMessage(idp, COLOR_ORANGE, string);
			SendClientMessage(playerid, COLOR_ORANGE, "PM envoye");
		} else {
			SendClientMessage(playerid, COLOR_ORANGE, "[PM] Le joueur n'est pas connecte");
		}
		
		return 1;
	}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)