I need a warn cmd
#1

I need a str cmd warn command anyone help me out?
Reply
#2

pawn Код:
if(strcmp(cmd, "/warn", true) == 0)
    {
        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;
    }
And change YOURCOLOR to the colors you want.
Reply
#3

pWarns?
Reply
#4

C:\Users\Mike\Documents\Backup\gamemodes\eR.pwn(51 57) : error 017: undefined symbol "pWarns"
C:\Users\Mike\Documents\Backup\gamemodes\eR.pwn(51 60) : error 017: undefined symbol "string"
C:\Users\Mike\Documents\Backup\gamemodes\eR.pwn(51 60) : error 017: undefined symbol "string"
C:\Users\Mike\Documents\Backup\gamemodes\eR.pwn(51 60) : error 029: invalid expression, assumed zero
C:\Users\Mike\Documents\Backup\gamemodes\eR.pwn(51 60) : fatal error 107: too many error messages on one line

Sorry double post
Reply
#5

Okey wait.. maybe you wan't this make easier, faster, better than strcmp? i can help you but you just need to be better than other what using strcmp. It's really easy to use ZCMD, Sscanf, enum. Wan't my help? Or you for real wan't this strcmp?
Reply
#6

pawn Код:
new string[128];
under public onplayercommandtext.
Or better take Riddick's advice.
Reply
#7

Yer but if I change to ZCMD I will have to change all my scripts, I would rather stay with strcmp
Reply
#8

Next time when you will start making Gamemode just hit here on forum to get help with sscanf, zcmd, enum and all options to optimaze your script. Just.. all what you wan't.
Reply
#9

If I do
pawn Код:
new string[128];
after what you said it messes my commands up....
Reply
#10

pawn Код:
if(strcmp(cmd, "/warn", true) == 0)
    {
        new string[128];
Reply
#11

Ye, you right Riddick and MadeMan, sorry for my mistake.
Reply
#12

Whats pWarn?

Fixed


Thanks ALL!
Reply
#13

Ok I did /warn 1 Test and it said

"1 is not an active player"
Reply
#14

Uhm, make sure the player who you warn is connected to your server ^^
This works fine for me.
Reply
#15

I used it on my self and it didnt work?
Reply
#16

Ok its weird some random person just used it on me he is not mod or anything
Reply
#17

Oh, then remove
pawn Код:
PlayerInfo[playerid][pAdmin]
and put admin enum as you have it in your gamemode
Reply
#18

I changed that to my admin script instead and that was what happened
Reply
#19

Post here please you changes
Reply
#20

When i was creating my Gamemode for the first time i used strcmp.. this gamemode has got over 120 command. Then one day i get learnt about DCMD. Now.. think how many time i spent to change this all commands to DCMD? It was a long time ago.. yea.. i remember this times, ah..

The moral is:
Change your commands to ZCMD and Sscanf.. it will be safer for your server.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)