/warn is not working
#1

Hai again

I made another command but it's not working correctly (/warn)
How it works?
1)It's supposed to issue a warn to a player but it warns the admin who executed the command
2)The player's name & the reason is not appering. EXAMPLE : (0) has been warned. Reason: . it should show the player's name and the reason but it doesn't, it just shows the player's ID and instead of showing the reason it just shows a point.

pawn Код:
dcmd(warn,4,cmdtext);
pawn Код:
dcmd_warn(playerid,params[])
{
    new string[128];
    new giveplayerid;
    new giveplayer;
    new cmdreason[100];
    if(PlayerInfo[playerid][pAdmin] < 1)
    if(sscanf(params,"us[100]",giveplayerid,cmdreason))
    {
        SendClientMessage(playerid,COLOR_NUB,"USAGE: /warn <ID> <Reason>");
        return 1;
    }
    if(!IsPlayerConnected(giveplayerid))
    {
        format(string,sizeof(string),"The player ID %s[%i] is not connected to the server. You cannot warn him.",giveplayer,giveplayerid);
        SendClientMessage(playerid,COLOR_NUB,string);
        return 1;
    }
    format(string,sizeof(string),"{FFFFFF}__**Punished**__{FFFFFF} %s(%d) Has been warned. {FFFFFF}Reason: %s{FFFFFF}",giveplayer,giveplayerid,cmdreason);
    SendClientMessageToAll(-1,string);
    return 1;
}
Thanks
Reply
#2

pawn Код:
dcmd_warn(playerid,params[])
{
    new string[128], giveplayerid, giveplayer[MAX_PLAYER_NAME], cmdreason[64];
    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        if(sscanf(params,"us[64]", giveplayerid, cmdreason)) SendClientMessage(playerid,COLOR_NUB,"USAGE: /warn <ID> <Reason>");
        if(giveplayerid == INVALID_PLAYER_ID)
        {
            /*
            This area, if the player is not connected? How can it show the ID? So you can just delete the '[%i]' and the '%s' if he's not online.
            format(string,sizeof(string),"The player ID %s[%i] is not connected to the server. You cannot warn him.",giveplayer,giveplayerid);
            SendClientMessage(playerid,COLOR_NUB,string);
            */

            format(string,sizeof(string),"The player ID is not connected to the server. You cannot warn him.",giveplayer,giveplayerid);
            SendClientMessage(playerid,COLOR_NUB,string);
            return 1;
        }
        GetPlayerName(giveplayerid, giveplayer, siezof(giveplayer));
        format(string,sizeof(string),"{FFFFFF}__**Punished**__{FFFFFF} %s(%d) Has been warned. {FFFFFF}Reason: %s{FFFFFF}",giveplayer,giveplayerid,cmdreason);
        SendClientMessageToAll(-1,string);
    }
    else SendClientMessage(playerid, -1, "You're not authorized to use this command!");
    return 1;
}
Try it. Tell me if something's wrong.
Reply
#3

pawn Код:
dcmd_warn(playerid,params[])
{
    new giveplayerid, cmdreason[64];
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1, "You're not authorized to use this command!");
    if(sscanf(params,"us[64]", giveplayerid, cmdreason)) SendClientMessage(playerid,COLOR_NUB,"USAGE: /warn <ID> <Reason>");
    if(strlen(cmdreason) > 64) return SendClientMessage(playerid, COLOR_NUB, "Reason must be less than 65 characters long.");
    new string[150], giveplayer[MAX_PLAYER_NAME];
    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
    if(giveplayerid == INVALID_PLAYER_ID || !IsPlayerConnected(giveplayerid))
    {
        format(string,sizeof(string),"The player ID %s[%i] is not connected to the server. You cannot warn him.",giveplayer,giveplayerid);
        return SendClientMessage(playerid,COLOR_NUB,string);
    }
    format(string,sizeof(string),"{FFFFFF}__**Punished**__{FFFFFF} %s(%d) Has been warned. {FFFFFF}Reason: %s{FFFFFF}",giveplayer,giveplayerid,cmdreason);
    SendClientMessageToAll(-1,string);
    }
    return 1;
}
Only a few little mistakes.
Reply
#4

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
pawn Код:
dcmd_warn(playerid,params[])
{
    new giveplayerid, cmdreason[64];
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1, "You're not authorized to use this command!");
    if(sscanf(params,"us[64]", giveplayerid, cmdreason)) SendClientMessage(playerid,COLOR_NUB,"USAGE: /warn <ID> <Reason>");
    if(strlen(cmdreason) > 64) return SendClientMessage(playerid, COLOR_NUB, "Reason must be less than 65 characters long.");
    new string[150], giveplayer[MAX_PLAYER_NAME];
    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
    if(giveplayerid == INVALID_PLAYER_ID || !IsPlayerConnected(giveplayerid))
    {
        format(string,sizeof(string),"The player ID %s[%i] is not connected to the server. You cannot warn him.",giveplayer,giveplayerid);
        return SendClientMessage(playerid,COLOR_NUB,string);
    }
    format(string,sizeof(string),"{FFFFFF}__**Punished**__{FFFFFF} %s(%d) Has been warned. {FFFFFF}Reason: %s{FFFFFF}",giveplayer,giveplayerid,cmdreason);
    SendClientMessageToAll(-1,string);
    }
    return 1;
}
Only a few little mistakes.
Wait how? It's just a few like additions.

EDIT: And some edits, but in other ways than mines.
Reply
#5

Quote:
Originally Posted by JustinAn
Посмотреть сообщение
Wait how? It's just a few like additions.

EDIT: And some edits, but in other ways than mines.
No...
He was modified it a lot since your code will give errors.
Reply
#6

I don't seem to see what's wrong..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)