Admin Warning System help
#1

Hey!

I got the following command:
Код:
CMD:awarn( playerid, cmdtext[] ) {

	new targetid,
		string[128];
	if(PlayerInfo[playerid][pAdmin] < 6)
	    return SendClientMessage(playerid, COLOR_RED, "SERVER: You can't use this command.");
	if(sscanf(cmdtext, "u", targetid))
	    return SendClientMessage(playerid, COLOR_RED, "USAGE: /awarn [admin]");
	if(!IsPlayerConnected(targetid) || PlayerInfo[targetid][pAdmin] == 0)
	    return SendClientMessage(playerid, COLOR_RED, "SERVER: Playerid is not an active ID or playerid is NOT an admin!");
	if(PlayerInfo[playerid][pAdmin] >= 1) {
	
	    PlayerInfo[playerid][pAdminWarns] = PlayerInfo[playerid][pAdminWarns] + 1;
	    format(string, sizeof(string), "AdmWarning: %s has warned admin %s (Warn: #%d)", GetOOCName(playerid), GetOOCName(targetid), PlayerInfo[targetid][pAdminWarns]);
	    SendMessageToAdmins(COLOR_RED, string, 1);
	    printf("AdmWarning: %s has warned admin %s (Warn: #%d)", GetOOCName(playerid), GetOOCName(targetid), PlayerInfo[targetid][pAdminWarns]);
	    return 1;
	}
	else if(PlayerInfo[targetid][pAdminWarns] == 2)
	{
	    PlayerInfo[targetid][pAdminWarns] = 0;
	    PlayerInfo[targetid][pAdmin] = PlayerInfo[playerid][pAdmin] - 1;
	    format(string, sizeof(string), "AdmWarning: %s has been demoted by 1 level by SYSTEM because he had gathered 3 admin warnings!", GetOOCName(targetid));
	    SendMessageToAdmins(COLOR_RED, string, 1);
	    printf("AdmWarning: %s was demoted by 1 level by SYSTEM because he had had gathered 3 admin warnings", GetOOCName(targetid));
	    return 1;
	}
	return 0;
}
It all works fine but it keeps adding (+1) to the targetid's adminwarnings. Example: /awarn 0 keeps warning him and his pAdminWarns goes up by +1.
As stated in the end, it doesn't demote him if he's about to get his 3rd. I can warn him up to 100.

Problem #2:
Код:
CMD:me( playerid, cmdtext[] ) {

	if(IsPlayerConnected(playerid))
	{
		new message[128],
	   	 	string[128];

		if(sscanf(cmdtext, "s[126]", message))	return SendClientMessage(playerid, COLOR_GREY, "USAGE: /me [action]");
		format(string, sizeof(string), "* %s %s", GetICName(playerid), message);
		SendNearByMessage(playerid, COLOR_INDIGO, string, 10);
		return 1;
	} else {
		SendClientMessage(playerid, COLOR_RED, "SERVER: You are not connected yet.");
	}
	return 0;
}
I got the stated command but when I do /me text it displays "USAGE: /me [action]". It doesn't work at all, it reads it like I've no text.

I can't seem to figure it out what's the problem.

Thanks!
Reply
#2

Код:
if(PlayerInfo[playerid][pAdmin]  < 2) {
	
	    PlayerInfo[playerid][pAdminWarns] = PlayerInfo[playerid][pAdminWarns] + 1;
	    format(string, sizeof(string), "AdmWarning: %s has warned admin %s (Warn: #%d)", GetOOCName(playerid), GetOOCName(targetid), PlayerInfo[targetid][pAdminWarns]);
	    SendMessageToAdmins(COLOR_RED, string, 1);
	    printf("AdmWarning: %s has warned admin %s (Warn: #%d)", GetOOCName(playerid), GetOOCName(targetid), PlayerInfo[targetid][pAdminWarns]);
	    return 1;
	}
	else if(PlayerInfo[targetid][pAdminWarns] == 2)
	{
	    PlayerInfo[targetid][pAdminWarns] = 0;
	    PlayerInfo[targetid][pAdmin] = PlayerInfo[playerid][pAdmin] - 1;
	    format(string, sizeof(string), "AdmWarning: %s has been demoted by 1 level by SYSTEM because he had gathered 3 admin warnings!", GetOOCName(targetid));
	    SendMessageToAdmins(COLOR_RED, string, 1);
	    printf("AdmWarning: %s was demoted by 1 level by SYSTEM because he had had gathered 3 admin warnings", GetOOCName(targetid));
	    return 1;
	}
solution to problem 1...

You are actually checking if warns are greater than one and then checking for 2 so the condition of first one will be accomplished. So better use it like if its less than the limit you want
That might help.
.
Reply
#3

I couldn't catch something else what you edited than:
PHP код:
if(PlayerInfo[playerid][pAdmin]  < 2
Which I think that's not what I want. I want only admins that are level 6 to be able to use this command.

Could you be more specific and elaborate, please?

// You were given +1 rep for (trying to) help(ing) me. You probably did help me but I couldn't catch your drift.

Waiting on more replies.
Reply
#4

whats wrong with me ._.

Ok you are doing it really wrong. Heres what you really do.
(Not everything wrong but a part was wrong and a line was to be added)
1. You get targetid.(you have done that)
2. You check the TARGETIDS admin stats (nope you havent)
3. Check for targetids warns(you hadnt for first bracket)
4. Reduce his level(yes you have)

Heres what you actually do..

Код:
if(PlayerInfo[targetid][pAdmin] >= 1)// check if target selected has admin level greater than 1
{
if(PlayerInfo[targetid][pAdminWarns]  < 2) {// check if he has less than two warns
	
	    PlayerInfo[targetid][pAdminWarns] ++;// same as incrementing his warns
	    format(string, sizeof(string), "AdmWarning: %s has warned admin %s (Warn: #%d)", GetOOCName(playerid), GetOOCName(targetid), PlayerInfo[targetid][pAdminWarns]);
	    SendMessageToAdmins(COLOR_RED, string, 1);
	    printf("AdmWarning: %s has warned admin %s (Warn: #%d)", GetOOCName(playerid), GetOOCName(targetid), PlayerInfo[targetid][pAdminWarns]);
	    return 1;
	}
	else if(PlayerInfo[targetid][pAdminWarns] == 2)
	{
	    PlayerInfo[targetid][pAdminWarns] = 0;
	    PlayerInfo[targetid][pAdmin]--; // same as reducing his levep
	    format(string, sizeof(string), "AdmWarning: %s has been demoted by 1 level by SYSTEM because he had gathered 3 admin warnings!", GetOOCName(targetid));
	    SendMessageToAdmins(COLOR_RED, string, 1);
	    printf("AdmWarning: %s was demoted by 1 level by SYSTEM because he had had gathered 3 admin warnings", GetOOCName(targetid));
	    return 1;
	}
}
else return SendClientMessage(//the target isnt admin so tell the main admin);
Reply
#5

I didn't say that there's something wrong with you. It was that I couldn't understand what you were trying to say.
It has been fixed. Thank you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)