SA-MP Forums Archive
/warn Commmand - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /warn Commmand (/showthread.php?tid=286809)



/warn Commmand - V_LOPE - 30.09.2011

Problem Solved


Re: /warn Commmand - V_LOPE - 01.10.2011

Anyone? ^^^


Re: /warn Commmand - Yamoo - 01.10.2011

Try asking in the request thread, cheers.


Re: /warn Commmand - Super_Panda - 01.10.2011

Try this

pawn Код:
if(strcmp(cmd, "/warn", true) == 0)
    {
 new string[128];
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, YOURCOLOR, "USAGE: /warn [playerid/PartOfName] [reason]");
                return 1;
            }
            giveplayerid = ReturnUser(tmp);
            if (PlayerInfo[playerid][pAdmin] >= 1)
            {
                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, YOURCOLOR, "USAGE: /warn [playerid/PartOfName] [reason]");
                            return 1;
                        }
                        new year, month,day;
                        getdate(year, month, day);
                        format(string, sizeof(string), "You warned %s, reason: %s", giveplayer, (result));
                        SendClientMessage(playerid, COLOR_YOURCOLOR, string);
                        format(string, sizeof(string), "You were warned by %s, reason: %s", sendername, (result));
                        SendClientMessage(giveplayerid, COLOR_YOURCOLOR, string);
                        format(string, sizeof(string), "AdmCmd: %s was warned by %s, reason: %s", giveplayer, sendername, (result));
                        SendClientMessageToAll(0xE42217FF, string);
                        format(string, sizeof(string), "AdmCmd: %s was warned by %s, reason: %s (%d-%d-%d)", giveplayer, sendername, (result),month,day,year);
                        return 1;
                    }
                }//not connected
            }
            else
            {
                format(string, sizeof(string), "   %d is not an active player.", giveplayerid);
                SendClientMessage(playerid, YOURCOLOR, string);
            }
        }
        return 1;
    }



Re: /warn Commmand - grand.Theft.Otto - 01.10.2011

Quote:
Originally Posted by Super_Panda
Посмотреть сообщение
Try this

pawn Код:
if(strcmp(cmd, "/warn", true) == 0)
    {
 new string[128];
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, YOURCOLOR, "USAGE: /warn [playerid/PartOfName] [reason]");
                return 1;
            }
            giveplayerid = ReturnUser(tmp);
            if (PlayerInfo[playerid][pAdmin] >= 1)
            {
                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, YOURCOLOR, "USAGE: /warn [playerid/PartOfName] [reason]");
                            return 1;
                        }
                        new year, month,day;
                        getdate(year, month, day);
                        format(string, sizeof(string), "You warned %s, reason: %s", giveplayer, (result));
                        SendClientMessage(playerid, COLOR_YOURCOLOR, string);
                        format(string, sizeof(string), "You were warned by %s, reason: %s", sendername, (result));
                        SendClientMessage(giveplayerid, COLOR_YOURCOLOR, string);
                        format(string, sizeof(string), "AdmCmd: %s was warned by %s, reason: %s", giveplayer, sendername, (result));
                        SendClientMessageToAll(0xE42217FF, string);
                        format(string, sizeof(string), "AdmCmd: %s was warned by %s, reason: %s (%d-%d-%d)", giveplayer, sendername, (result),month,day,year);
                        return 1;
                    }
                }//not connected
            }
            else
            {
                format(string, sizeof(string), "   %d is not an active player.", giveplayerid);
                SendClientMessage(playerid, YOURCOLOR, string);
            }
        }
        return 1;
    }
Hmm, so you expect the topic starter to already have this enumeration:

PlayerInfo[playerid][pAdmin]

in his script ?

Stop copying and pasting stuff without explaining.


Re: /warn Commmand - V_LOPE - 01.10.2011

No Guys I Wont The Code For (OnPlayerClickPlayer)


Re: /warn Commmand - Cjgogo - 01.10.2011

pawn Код:
#define DIALOG_WARN 1
We need the dialog for the warning text you will use.

pawn Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}
playerid = You;
clickedplayerid = The player you clicked.
source(not needed in this case) = of couurse the scoreboard;

pawn Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
        if(PlayerInfo[playerid][pAdmin] >=1)
       {
          ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"WarnText","Please type your warning reason here","Submit","Cancel"); // this will show you a dialog(like the one for register system,where you type in a password,but instead,you'll type here the warning reason)
       }
    return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
   if(dialogid==DIALOG_WARN) // our dialog defined above at the beggining of my reply
   {
       if(response==0) return SendClientMessage(playerid,COLOR_RED,"Operation aborted"); // you selected cancel
       if(response==1)
       {
           if(!strlen(inputtext)) return SendClientMessage(playerid,COLOR_RED,"You didn't type anything in the box"); // you typed no text,no warning reason
           if(strlen(inputtext)) // you typed in a reason
          {        
             new pID=clickedplayerid; // the player id you wanna give the warn
             new wName[MAX_PLAYER_NAME]; // you can call this as you wish,but I though of wName( warned name)
            GetPlayerName(pID,wName,sizeof(wName)); // gets the pID name
            new string[120]; // the string we gonna use for the warning statement
            format(string,sizeof(string),"%s(%d) has been warned by an admin.Reason:%s",wName,pID,inputtext); // the statement itself sending the warned name,his ID,and the reason
            SendClientMessageToAll(COLOR_RED,string); // the message is sent to every player
          }
   return true;
}
I don't really know if that works,but it should,you know the only thing I'm not sure about is if the system can read the pID as the clickedplayerid,so if you have some problems,than maybe some1 else will try to help you by correcting my post.


Re: /warn Commmand - V_LOPE - 01.10.2011

Quote:
Originally Posted by Cjgogo
Посмотреть сообщение
pawn Код:
#define DIALOG_WARN 1
We need the dialog for the warning text you will use.

pawn Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}
playerid = You;
clickedplayerid = The player you clicked.
source(not needed in this case) = of couurse the scoreboard;

pawn Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
        if(PlayerInfo[playerid][pAdmin] >=1)
       {
          ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"WarnText","Please type your warning reason here","Submit","Cancel"); // this will show you a dialog(like the one for register system,where you type in a password,but instead,you'll type here the warning reason)
       }
    return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
   if(dialogid==DIALOG_WARN) // our dialog defined above at the beggining of my reply
   {
       if(response==0) return SendClientMessage(playerid,COLOR_RED,"Operation aborted"); // you selected cancel
       if(response==1)
       {
           if(!strlen(inputtext)) return SendClientMessage(playerid,COLOR_RED,"You didn't type anything in the box"); // you typed no text,no warning reason
           if(strlen(inputtext)) // you typed in a reason
          {        
             new pID=clickedplayerid; // the player id you wanna give the warn
             new wName[MAX_PLAYER_NAME]; // you can call this as you wish,but I though of wName( warned name)
            GetPlayerName(pID,wName,sizeof(wName)); // gets the pID name
            new string[120]; // the string we gonna use for the warning statement
            format(string,sizeof(string),"%s(%d) has been warned by an admin.Reason:%s",wName,pID,inputtext); // the statement itself sending the warned name,his ID,and the reason
            SendClientMessageToAll(COLOR_RED,string); // the message is sent to every player
          }
   return true;
}
I don't really know if that works,but it should,you know the only thing I'm not sure about is if the system can read the pID as the clickedplayerid,so if you have some problems,than maybe some1 else will try to help you by correcting my post.
Thanks It Works! ..
But I Wont After 3 Warning He Get Kick How I Can Do that?


Re: /warn Commmand - Jafet_Macario - 01.10.2011

Cjgogo edit:
pawn Код:
new Warnings[MAX_PLAYERS]; // TOP


Warnings[playerid] = 0; // OnPlayerConnect

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid==DIALOG_WARN) //
    {
        if(response==0) return SendClientMessage(playerid,COLOR_RED,"Operation aborted");
        if(response==1)
        {
            if(!strlen(inputtext)) return SendClientMessage(playerid,COLOR_RED,"You didn't type anything in the box");
            new pID = clickedplayerid;
            new wName[MAX_PLAYER_NAME];
            GetPlayerName(pID,wName,sizeof(wName));
            new string[120];
            format(string,sizeof(string),"%s(%d) has been warned by an admin.Reason:%s",wName,pID,inputtext);
            SendClientMessageToAll(COLOR_RED,string);
            Warnings[pID] += 1;
            if(Warnings[pID] >= 3)
            {
                SendClientMessage(pID, -1, "3/3 Warnings, kicked"):
                Kick(pID);
            }
        }
    }
    return true;
}



Re: /warn Commmand - V_LOPE - 01.10.2011

Quote:
Originally Posted by Jafet_Macario
Посмотреть сообщение
Cjgogo edit:
pawn Код:
new Warnings[MAX_PLAYERS]; // TOP


Warnings[playerid] = 0; // OnPlayerConnect

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid==DIALOG_WARN) //
    {
        if(response==0) return SendClientMessage(playerid,COLOR_RED,"Operation aborted");
        if(response==1)
        {
            if(!strlen(inputtext)) return SendClientMessage(playerid,COLOR_RED,"You didn't type anything in the box");
            new pID = clickedplayerid;
            new wName[MAX_PLAYER_NAME];
            GetPlayerName(pID,wName,sizeof(wName));
            new string[120];
            format(string,sizeof(string),"%s(%d) has been warned by an admin.Reason:%s",wName,pID,inputtext);
            SendClientMessageToAll(COLOR_RED,string);
            Warnings[pID] += 1;
            if(Warnings[pID] >= 3)
            {
                SendClientMessage(pID, -1, "3/3 Warnings, kicked"):
                Kick(pID);
            }
        }
    }
    return true;
}
Thanks Problem Solved