#1

I'm creating my PM system but i'm stuck in /r
I always stuck in

Код:
*** You do not receive any PM ***
here is how i do it

pawn Код:
CMD:pm(playerid, params[])
{
    new id, msg[128], str[128];
    if(pData[playerid][Login] == 0) return SendClientMessage(playerid, COLOR_RED, "*** Please login first! ***");
    if(sscanf(params, "us[128]", id, msg)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /pm [playerid] [msg]");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "*** Player not connected ***");
    if(pData[id][NoPM] == 1) return SendClientMessage(playerid, COLOR_RED, "*** This player has disable his PM Recieving System! ***");
    PlayerPlaySound(id, 1085, 0.0, 0.0, 0.0);
    format(str, sizeof(str), "PM to %s(%d): %s", GetpName(id), id, msg);
    SendClientMessage(playerid, COLOR_YELLOW, str);
    SetPVarInt(id, "LastPM", playerid);
    format(str, sizeof(str), "PM from %s(%d): %s", GetpName(playerid), playerid, msg);
    SendClientMessage(id, COLOR_YELLOW, str);
    SendClientMessage(id, COLOR_YELLOW, "*** Use /r to reply in PM ***");
    return 1;
}

CMD:r(playerid, params[])
{
    new str[128], id;
    if(GetPVarInt(playerid, "LastPM"))
    {
        if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /r [msg]");
        PlayerPlaySound(id, 1085, 0.0, 0.0, 0.0);
        format(str, sizeof(str), "Reply PM to %s(%d): %s", GetpName(id), id, params);
        SendClientMessage(playerid, COLOR_YELLOW, str);
        format(str, sizeof(str), "%s(%d) has reply your PM: %s", GetpName(playerid), playerid, params);
        SendClientMessage(id, COLOR_YELLOW, str);
        SendClientMessage(id, COLOR_YELLOW, "*** Use /r to reply in PM ***");
    }
    else return SendClientMessage(playerid, COLOR_RED, "*** You don't have receive any PM! ***");
    return 1;
}
Reply
#2

Is the PM from ID 0


Also even if you did get it to not say that, it won't send it to anyone (you forgot to set id to GetPVarInt(playerid, "LastPM") )
Reply
#3

Actually i don't know what i'm doing i just follow Calgon tips:

Single Post by Calgon
Reply
#4

Quote:
Originally Posted by Romel
Посмотреть сообщение
Actually i don't know what i'm doing i just follow Calgon tips:

Single Post by Calgon
Well, clearing that PVar when they log out...is going to require a loop. You'll have to go through imo to much just to remove it...Just use something like this


pawn Код:
//Add this to your pData enum - LastPM

public OnPlayerConnect(playerid, params[])
{
    pData[playerid][LastPM] = -1; //add this under onplayerconnect
}

CMD:r(playerid, params[])
{
    new str[128], id = pData[playerid][LastPM];
    if(id == -1) return SendClientMessage(playerid, COLOR_RED, "*** You haven't received any PM! ***");
    if(IsPlayerConnected(id))
    {
        if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /r [msg]");
        PlayerPlaySound(id, 1085, 0.0, 0.0, 0.0);
        format(str, sizeof(str), "Reply PM to %s(%d): %s", GetpName(id), id, params);
        SendClientMessage(playerid, COLOR_YELLOW, str);
        format(str, sizeof(str), "%s(%d) has reply your PM: %s", GetpName(playerid), playerid, params);
        SendClientMessage(id, COLOR_YELLOW, str);
        SendClientMessage(id, COLOR_YELLOW, "*** Use /r to reply in PM ***");
    }
    else return SendClientMessage(playerid, COLOR_RED, "*** Player not connected! ***");
    return 1;
}


CMD:pm(playerid, params[])
{
    new id, msg[128], str[128];
    if(pData[playerid][Login] == 0) return SendClientMessage(playerid, COLOR_RED, "*** Please login first! ***");
    if(sscanf(params, "us[128]", id, msg)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /pm [playerid] [msg]");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "*** Player not connected ***");
    if(pData[id][NoPM] == 1) return SendClientMessage(playerid, COLOR_RED, "*** This player has disable his PM Recieving System! ***");
    PlayerPlaySound(id, 1085, 0.0, 0.0, 0.0);
    format(str, sizeof(str), "PM to %s(%d): %s", GetpName(id), id, msg);
    SendClientMessage(playerid, COLOR_YELLOW, str);
    format(str, sizeof(str), "PM from %s(%d): %s", GetpName(playerid), playerid, msg);
    SendClientMessage(id, COLOR_YELLOW, str);
    SendClientMessage(id, COLOR_YELLOW, "*** Use /r to reply in PM ***");
    pData[id][LastPM] = id;
    return 1;
}
Reply
#5

Thx for your help.
Anyway Do you have any idea how to prevent Reconnect when Kick(playerid); is use OnPlayerConnect?
Reply
#6

Quote:
Originally Posted by Romel
Посмотреть сообщение
Thx for your help.
Anyway Do you have any idea how to prevent Reconnect when Kick(playerid); is use OnPlayerConnect?
Not sure...You can probably set a timer that goes off after a second or so that kicks them
Reply
#7

Never Mind Fixed

change

pawn Код:
pData[id][LastPM] = id;
to

pawn Код:
pData[playerid][LastPM] = id;
Reply
#8

Just thought I'd throw this out there.
Quote:

PVars are automatically deleted when a player leaves the server (after OnPlayerDisconnect), meaning you don't have to manually reset variables for the next player who joins.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)