PM System Help
#1

i use this

Код:
if(!strcmp("/pm", cmdtext, true))
{
    tmp = strtok(cmdtext,idx);
    if(!strlen(tmp)) return SendClientMessage(playerid,0xFF0000FF,"USAGE: /PM (id) (message)");
    new id = strval(tmp);
    gMessage = strrest(cmdtext,idx);
    if(!strlen(gMessage)) return SendClientMessage(playerid,0xFF0000FF,"Usage: /pm (id) (message)");		
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0xFF0000FF,"/pm :Invalid ID");	
    GetPlayerName(id,iName,sizeof(iName));
    GetPlayerName(playerid,pName,sizeof(pName));
    format(Message,sizeof(Message),">> %s(%i): %s",iName,id,gMessage);
    SendClientMessage(playerid,0xFFD720FF,Message);
    format(Message,sizeof(Message),"** %s(%i): %s",pName,playerid,gMessage);
    SendClientMessage(id,0xFFD720FF,Message);
    PlayerPlaySound(id,1085,0.0,0.0,0.0);
    return 1;
}
i use this but when you go over a certain amount of letters it fucks the server up and no one can do cmds
Reply
#2

pawn Код:
if(!strcmp("/pm", cmdtext, true))
{
    new tmp = strtok(cmdtext,idx);
    if(!strlen(tmp)) return SendClientMessage(playerid,0xFF0000FF,"USAGE: /PM (id) (message)");
    new id, gMessage, iName, pName, Message[196];
    id = strval(tmp);
    gMessage = strrest(cmdtext,idx);
    if(!strlen(gMessage)) return SendClientMessage(playerid,0xFF0000FF,"Usage: /pm (id) (message)");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0xFF0000FF,"/pm :Invalid ID");
    GetPlayerName(id,iName,sizeof(iName));
    GetPlayerName(playerid,pName,sizeof(pName));
    format(Message,sizeof(Message),">> %s(%i): %s",iName,id,gMessage);
    SendClientMessage(playerid,0xFFD720FF,Message);
    format(Message,sizeof(Message),"** %s(%i): %s",pName,playerid,gMessage);
    SendClientMessage(id,0xFFD720FF,Message);
    PlayerPlaySound(id,1085,0.0,0.0,0.0);
    return 1;
}
And i recommend to use sscanf with ZCMD
Reply
#3

pawn Код:
CMD:pm( playerid, params[ ] )
{
    new
        g_pmString [ 256 ],
        pName      [  24 ],
        oName      [  24 ],
        P_ID,
        P_MSG      [ 256 ]
    ;
   
    if( sscanf ( params, "is", P_ID, P_MSG ) )
                        return SendClientMessage( playerid, COLOR_WHITE, "/pm [id] [message]");

    if (!IsPlayerConnected ( P_ID ) )
                        return SendClientMessage( playerid, COLOR_RED, "That player is not connected! ");

    if ( P_ID == playerid )
                        return SendClientMessage( playerid, COLOR_RED, "You cannot PM yourself! ");
                       
    GetPlayerName( playerid, pName, sizeof ( pName ) );
    GetPlayerName( P_ID,     oName, sizeof ( oName ) );
   
    format( g_pmString, sizeof ( g_pmString ), "PM sent to: %s (ID: %d): %s", oName, P_ID, P_MSG );
    SendClientMessage( playerid, COLOR_YELLOW, g_pmString );
   
    format( g_pmString, sizeof ( g_pmString ), "PM from %s (ID: %d): %s", pName, playerid, P_MSG );
    SendClientMessage( P_ID, COLOR_ORANGE, g_pmString );
   
    return 1;
}
Here you go.
Next time use sscanf is more easier and looks clean
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)