[HELP]Can someone make for me [/pm] ?[+REP]
#1

Hello,
I want to make a [/pm] command for admins & helpers level 1+.
My Player info code :
Код:
Admin : if (PlayerInfo[playerid][pAdmin] >= 1)
Helper: if (PlayerInfo[playerid][pHelper] >= 1)
I want it to be like [/w] command but it be [/pm] and for admins and send the player : PM from Admin %s : Text
And if pm sender is a helper : PM from Helper %s : Text.
[/w] Command :
pawn Код:
if(strcmp(cmd, "/whisper", true) == 0 || strcmp(cmd, "/w", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pMuted] == 1)
            {
                SendClientMessage(playerid, TEAM_CYAN_COLOR, "You cannot speak, you have been silenced");
                return 1;
            }
            if(gPlayerLogged[playerid] == 0)
            {
                SendClientMessage(playerid, COLOR_WHITE, "You havent logged in yet");
                return 1;
            }
            if(PlayerInfo[playerid][pLevel] < 2)
            {
                SendClientMessage(playerid, COLOR_WHITE, "You need level 2 to use this");
                return 1;
            }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GREY, "USAGE: /whisper [playerid/PartOfName] [whisper text]");
                return 1;
            }
            giveplayerid = ReturnUser(tmp);
            if (IsPlayerConnected(giveplayerid))
            {
                if(giveplayerid != INVALID_PLAYER_ID)
                {
                    if(HidePM[giveplayerid] > 0)
                    {
                        SendClientMessage(playerid, COLOR_LIGHTGREEN, "That player is blocking Whispers");
                        return 1;
                    }
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                    if(giveplayerid == playerid)
                    {
                        format(string, sizeof(string), "%s mutters somthing", sendername);
                        ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    }
                    new length = strlen(cmdtext);
                    while ((idx < length) && (cmdtext[idx] <= ' '))
                    {
                        idx++;
                    }
                    new offset = idx;
                    new result[64];
                    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                    {
                        result[idx - offset] = cmdtext[idx];
                        idx++;
                    }
                    result[idx - offset] = EOS;
                    if(!strlen(result))
                    {
                        SendClientMessage(playerid, COLOR_GREY, "USAGE: /whisper [playerid/PartOfName] [whisper text]");
                        return 1;
                    }
                    format(string, sizeof(string), "{FF8000}[ID: %d] {FFFFFF}%s {FF8000}Whisper: {FFFFFF}%s", playerid, sendername, (result));
                    SendClientMessage(giveplayerid, 0xFFFFFFFF, string);
                    format(string, sizeof(string), "{FFFFFF}Whisper sent to {FF8000}[ID: %d] {FFFFFF}%s: {FF8000}%s", giveplayerid, giveplayer, (result));
                    SendClientMessage(playerid, 0xFFFFFFFF, string);
                    SBizzInfo[1][sbTill] += txtcost / 2;
                    ExtortionSBiz(1, txtcost / 2);
                    return 1;
                }
            }
            else
            {
                    format(string, sizeof(string), "That player is not connected", giveplayerid);
                    SendClientMessage(playerid, COLOR_WHITE, string);
            }
        }
        return 1;
    }
Reply
#2

do this will work!

Код:
dcmd_pm(playerid, params[])
{
        if(PlayerInfo[playerid][pLevel] < 1)
            {
                SendClientMessage(playerid, COLOR_WHITE, "You need level 2 to use this");
                return 1;
            }

         if(PlayerInfo[playerid][pHelper] == 1)
            {
                SendClientMessage(playerid, TEAM_CYAN_COLOR, "you are not a helper.");
                return 1;
            }

        new pID, text[128], string[128];
        if(sscanf(params, "us", pID, text)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /pm (nick/id) (message) - Enter a valid Nick / ID");
        if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected.");
        if(pID == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot PM yourself.");
        format(string, sizeof(string), "%s (%d) is not accepting private messages at the moment.", PlayerName(pID), pID);
        if(pInfo[pID][NoPM] == 1) return SendClientMessage(playerid, COLOR_RED, string);
        format(string, sizeof(string), "(( PM to %s: %s ))", PlayerName(pID), text);
        SendClientMessage(playerid, COLOR_YELLOW, string);
        format(string, sizeof(string), "(( PM from %s: %s ))", PlayerName(playerid), text);
        SendClientMessage(pID, COLOR_YELLOW, string);
        pInfo[pID][Last] = playerid;
        return 1;
}
Reply
#3

Quote:
Originally Posted by Barnwell
Посмотреть сообщение
do this will work!

Код:
dcmd_pm(playerid, params[])
{
        if(PlayerInfo[playerid][pLevel] < 1)
            {
                SendClientMessage(playerid, COLOR_WHITE, "You need level 2 to use this");
                return 1;
            }

         if(PlayerInfo[playerid][pHelper] == 1)
            {
                SendClientMessage(playerid, TEAM_CYAN_COLOR, "you are not a helper.");
                return 1;
            }

        new pID, text[128], string[128];
        if(sscanf(params, "us", pID, text)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /pm (nick/id) (message) - Enter a valid Nick / ID");
        if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected.");
        if(pID == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot PM yourself.");
        format(string, sizeof(string), "%s (%d) is not accepting private messages at the moment.", PlayerName(pID), pID);
        if(pInfo[pID][NoPM] == 1) return SendClientMessage(playerid, COLOR_RED, string);
        format(string, sizeof(string), "(( PM to %s: %s ))", PlayerName(pID), text);
        SendClientMessage(playerid, COLOR_YELLOW, string);
        format(string, sizeof(string), "(( PM from %s: %s ))", PlayerName(playerid), text);
        SendClientMessage(pID, COLOR_YELLOW, string);
        pInfo[pID][Last] = playerid;
        return 1;
}
That would cause me error ...
Reply
#4

pawn Код:
if(strcmp(cmd, "/whisper", true) == 0 || strcmp(cmd, "/w", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pMuted] == 1)
            {
                SendClientMessage(playerid, TEAM_CYAN_COLOR, "You cannot speak, you have been silenced");
                return 1;
            }
            if(gPlayerLogged[playerid] == 0)
            {
                SendClientMessage(playerid, COLOR_WHITE, "You havent logged in yet");
                return 1;
            }
            if(PlayerInfo[playerid][pHelper] >= 1 || PlayerInfo[playerid][pAdmin] >= 1)
            {
                SendClientMessage(playerid, COLOR_WHITE, "You need level 2 to use this or  helpers level 1+");
                return 1;
            }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GREY, "USAGE: /whisper [playerid/PartOfName] [whisper text]");
                return 1;
            }
            giveplayerid = ReturnUser(tmp);
            if (IsPlayerConnected(giveplayerid))
            {
                if(giveplayerid != INVALID_PLAYER_ID)
                {
                    if(HidePM[giveplayerid] > 0)
                    {
                        SendClientMessage(playerid, COLOR_LIGHTGREEN, "That player is blocking Whispers");
                        return 1;
                    }
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                    if(giveplayerid == playerid)
                    {
                        format(string, sizeof(string), "%s mutters somthing", sendername);
                        ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    }
                    new length = strlen(cmdtext);
                    while ((idx < length) && (cmdtext[idx] <= ' '))
                    {
                        idx++;
                    }
                    new offset = idx;
                    new result[64];
                    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                    {
                        result[idx - offset] = cmdtext[idx];
                        idx++;
                    }
                    result[idx - offset] = EOS;
                    if(!strlen(result))
                    {
                        SendClientMessage(playerid, COLOR_GREY, "USAGE: /whisper [playerid/PartOfName] [whisper text]");
                        return 1;
                    }
                    format(string, sizeof(string), "{FF8000}[ID: %d] {FFFFFF}%s {FF8000}Whisper: {FFFFFF}%s", playerid, sendername, (result));
                    SendClientMessage(giveplayerid, 0xFFFFFFFF, string);
                    format(string, sizeof(string), "{FFFFFF}Whisper sent to {FF8000}[ID: %d] {FFFFFF}%s: {FF8000}%s", giveplayerid, giveplayer, (result));
                    SendClientMessage(playerid, 0xFFFFFFFF, string);
                    SBizzInfo[1][sbTill] += txtcost / 2;
                    ExtortionSBiz(1, txtcost / 2);
                    return 1;
                }
            }
            else
            {
                    format(string, sizeof(string), "That player is not connected", giveplayerid);
                    SendClientMessage(playerid, COLOR_WHITE, string);
            }
        }
        return 1;
    }
Reply
#5

I didn't test it, but i hope it will work
PHP код:
if(strcmp(cmd"/pm"true) == 0)
{
if(
PlayerInfo[playerid][pAdmin] >= || PlayerInfo[playerid][pHelper] >= 1){
new 
idmsg[128],string[256];
tmp strtok(cmdtextidx);
   if(!
strlen(tmp))
   {
    
SendClientMessage(playerid, -1"USAGE: /pm [playerid] [message]");
    return 
1;
   }
id ReturnUser(tmp);
if(!
IsPlayerConnected(id)){
SendClientMessage(playerid, -1"USAGE: /pm [playerid] [message]");
return 
1;
}
msg strtok(cmdtextidx);
new 
name[40],sender[40];
GetPlayerName(idnamesizeof(name));
GetPlayerName(playeridsendersizeof(sender));
format(stringsizeof(string), "{FF8000}[ID: %d] {FFFFFF}%s {FF8000}PM: {FFFFFF}%s"playeridsendernamemsg);
SendClientMessage(id0xFFFFFFFFstring);
format(stringsizeof(string), "{FFFFFF}PM sent to {FF8000}[ID: %d] {FFFFFF}%s: {FF8000}%s"idnamemsg);
SendClientMessage(playerid0xFFFFFFFFstring);
}
return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)