warn command help
#1

Ok, so i got this /warn command that gives players warns now what my question is, How does it save it to the players? Like i'm trying to make it so it saves the reason of the warn also instead of just the amount of warns so when an admin types /getwarning it shows how many warns they have and the reason for those warns, How does it save it tho is what i wanna know

pawn Код:
if(strcmp(cmd, "/warn", true) == 0)
    {
    if(IsPlayerConnected(playerid))
    {
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
    SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /warn [playerid/PartOfName] [reason]");
    return 1;
    }
    if(IsStringAName(tmp))
    {
    giveplayerid = GetPlayerID(tmp);
    }
    else
    {
    giveplayerid = strval(tmp);
    }
    if ((IsPlayerAdmin(playerid)) || PlayerInfo[playerid][pAdmin] >= 6)
    {
    if(IsPlayerConnected(giveplayerid))
    {
    if(giveplayerid != INVALID_PLAYER_ID)
    {
    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
    GetPlayerName(playerid, sendername, sizeof(sendername));
    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_GRAD2, "USAGE: /warn [playerid/PartOfName] [reason]");
    return 1;
    }
    if(Warning[giveplayerid] == 3)
    {
    format(string, sizeof(string), "You warned %s, reason: %s,this was his final warning, now he's banned", giveplayer, (result));
    SendClientMessage(playerid, COLOR_RED, string);
    format(string, sizeof(string), "You were warned by %s, reason: %s, this was your last warning, now you'r banned", sendername, (result));
    SendClientMessage(giveplayerid, COLOR_RED, string);
    format(string, sizeof(string), "***Admin %s warned player %s (id: %d) and he was banned. Reason: %s ***", sendername, giveplayer, giveplayerid, tmp);
    ABroadCast(COLOR_YELLOW, string,1);
    Ban(giveplayerid);
    }
    if(Warning[giveplayerid] == 2)
    {
    format(string, sizeof(string), "You warned %s, reason: %s, it is his final warning(3/3)", giveplayer, (result));
    SendClientMessage(playerid, COLOR_RED, string);
    format(string, sizeof(string), "You were warned by %s, reason: %s, this is your last warning (3/3)", sendername, (result));
    SendClientMessage(giveplayerid, COLOR_RED, string);
    format(string, sizeof(string), "***Admin %s warned player %s (id: %d) (3/3). Reason: %s ***", sendername, giveplayer, giveplayerid, tmp);
    ABroadCast(COLOR_YELLOW, string,1);
    Warning[giveplayerid] = 3;
    }
    if(Warning[giveplayerid] == 1)
    {
    format(string, sizeof(string), "You warned %s, reason: %s, it is his 2nd warning (2/3)", giveplayer, (result));
    SendClientMessage(playerid, COLOR_RED, string);
    format(string, sizeof(string), "You were warned by %s, reason: %s, this is your second warning (2/3)", sendername, (result));
    SendClientMessage(giveplayerid, COLOR_RED, string);
    format(string, sizeof(string), "***Admin %s warned player %s (id: %d) (2/3). Reason: %s ***", sendername, giveplayer, giveplayerid, tmp);
    ABroadCast(COLOR_YELLOW, string,1);
    Warning[giveplayerid] = 2;
    }
    if(Warning[giveplayerid] == 0)
    {
    format(string, sizeof(string), "You warned %s, reason: %s, it is his 1st warning (1/3)", giveplayer, (result));
    SendClientMessage(playerid, COLOR_RED, string);
    format(string, sizeof(string), "You were warned by %s, reason: %s, this is your first warning (1/3)", sendername, (result));
    SendClientMessage(giveplayerid, COLOR_RED, string);
    format(string, sizeof(string), "***Admin %s warned player %s (id: %d) (1/3). Reason: %s ***", sendername, giveplayer, giveplayerid, (result));
    ABroadCast(COLOR_YELLOW, string,1);
    Warning[giveplayerid] = 1;
    }
    return 1;
    }
    }
    format(string, sizeof(string), " %d is not an active player.", giveplayerid);
    SendClientMessage(playerid, COLOR_GRAD1, string);
    }
    else
    {
    format(string, sizeof(string), " You are not authorised to use that command!");
    SendClientMessage(playerid, COLOR_GRAD1, string);
    }
    }
    return 1;
    }
Reply
#2

nothing yet?
Reply
#3

Ok, I got it to where it saves to player account. I have another question tho. it's set up to where an admin warns someone the admin give a reason before warning. I'm curious of how i would go about saving the reason to player account

These are under my Playerinfo [pinfo] that i'm gonna use to save the warns

pWreason1,
pWreason2,
pWreason3,

How would i set the /warn command to save the warning to those in player account.

So for example a admin types /getwarning and it shows how many warns they have then below that it gives the reason of the warn so an admin type

/warn [playerid] Deathmatching and for warning 2 /warn [playerid] Carkilling and for 3rd warn /warn [playerid] Flaming Admin and on the fourth they get autobanned

then admin types /getwarnings and it shows

Playername has 1/3 warns
Warning 1: Deathmatching

then when thye have 2 warning

Playername Has 2/3 warns
Warning 1: Deatmatching
Warning 2: Carkilling

Then if they have 3/3 and admin types /getwarning again
Warning 1eathmatching
Warning 2:Carkilling
Warning 3:Flaming Admin

The command above, All the
pawn Код:
if(Warning[giveplayerid] == {warn amount})
Have been changed to
pawn Код:
if (PlayerInfo[playerid][pWarn] == {warn amount})
Reply
#4

No one has anything? Dang i was hoping i could get a little help with this.
Reply
#5

use ZCMD its more easy
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)