private messages with zcmd and sscanf2(solved)
#2

pawn Код:
COMMAND:pm(playerid,params[])
{
    new ID;
    new PMstring[128];//the PM
    new string[128];//string used for SendClientMessage
    new Iname[MAX_PLAYER_NAME], Pname[MAX_PLAYER_NAME];
   

    if (sscanf(params, "dz", id, PMstring))
    //'d' is the ID datatype (integer) and will store the number the player wrote inside ID
    //'z', which stands for optional string (wiki.sa-mp.com/wiki/Fast_Commands#Data_types), is for saving reasons (strings which can have multiple spaces (sscanf parts strings by spaces unless you choose your own delimiter))
    //and will save everything, what the player typed after the id, inside 'PMstring'
    {//sscanf returns 1 (or -1) if the operation didn't end succesfully (the user made a mistake)
        SendClientMessage(playerid,red,"Usage: /pm (id) (message)");
        return 1;
    }
   
    GetPlayerName(ID,Iname,sizeof(Iname));
    GetPlayerName(playerid,Pname,sizeof(Pname));
   
  format(string,sizeof(string),"PM from %i[%s]: %s",playerid,Pname,PMstring);
    SendClientMessage(ID,0xFFD720FF,string);
    format(string,sizeof(string),"PM To %s: %s",Iname,PMstring);
    SendClientMessage(playerid,0xFFD720FF,string);
    PlayerPlaySound(ID,1085,0.0,0.0,0.0);
    return 1;
}
Reply


Messages In This Thread
private messages with zcmd and sscanf2(solved) - by iggy1 - 31.05.2010, 08:38
Re: private message with zcmd and sscanf (help please) - by dice7 - 31.05.2010, 08:59
Re: private message with zcmd and sscanf (help please) - by NewTorran - 31.05.2010, 09:01
Re: private message with zcmd and sscanf (help please) - by dice7 - 31.05.2010, 09:02
Re: private message with zcmd and sscanf (help please) - by iggy1 - 31.05.2010, 09:06

Forum Jump:


Users browsing this thread: 5 Guest(s)