Problem with /warn
#1

Hello again,

I have a question with my /warn command. I use dcmd_warn and I nearly script it to the end. Now I have a little problem and I dunno how to fix it.

Код:
dcmd_warn(playerid,params[])
{
	new year, month, day; getdate(year, month, day);
	new hour, minute, second; gettime(hour, minute, second);
	new ReturnPlayer, pName[24], ReturnUserName[24], str[128], Reason[128], string[256];
	{
 	if(PlayerInfo[playerid][AdminLevel] < 1) return false;
 	if(sscanf(params,"ds",ReturnPlayer,Reason)) return SendClientMessage(playerid, COLOR_WHITE,"USAGE: /warn [playerid] [reason]");
	if (!IsPlayerConnected(ReturnPlayer)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "Invalid playerID!");
	GetPlayerName(playerid, pName, sizeof(pName));
	GetPlayerName(ReturnPlayer, ReturnUserName, sizeof(ReturnUserName));
 	format(str,sizeof(str),"ADMIN: %s has been warned by Administrator %s [Reason: %s] (%d/3)",ReturnUserName, pName, Reason,warnings);
	SendClientMessageToAll(COLOR_BRIGHTRED, str);
 	format(str,sizeof(str),"%s has been warned by Administrator %s [Reason: %s] (Warns: %d/3) (%d.%d.%d)",ReturnUserName, pName, Reason,warnings, year, month, day);
	format(str, sizeof(str), "ADMIN: %s (ID: %d) has warned %s (ID: %d) Reason: %s", pName, playerid, ReturnUserName, ReturnPlayer, Reason);
	SendAdminMsg(COLOR_WHITE, str);
 	return 1;
	}
	if(PlayerInfo[playerid][Warnings] == 3)
	{

	new File:KickFile = fopen("logs/KickLog.txt", io_append);
	SendClientMessage(playerid, COLOR_BRIGHTRED, "You have been automatically kicked. Reason: (3 Warnings)");
	format(str, sizeof(str), "[Server] %s has been kicked by Administrator %s [Reason: 3 Warnings]", ReturnUserName, pName);
	format(str,sizeof(str),"[Server] %s has been kicked by Administrator %s [Reason: 3 Warnings] (%d.%d.%d || %d:%d:%d)",ReturnUserName, pName, year, month, day);
	fwrite(KickFile, string);
	fclose(KickFile);
	}
	return 1;
}
When I type in the command it shows me "...Reason: bla bla Warns: 3/3. But I only type 1 warning and it shows me that i have 3 warns --> 3/3.
How can I fix that?
And it seems that the server donґt kick the player automatically when it reach 3 warns? Also help pls

Also it seems that when I warn a player the year, month and so on donґt display.

So I need help!
Reply
#2

pawn Код:
format(str,sizeof(str),"ADMIN: %s has been warned by Administrator %s [Reason: %s] (%d/3)",ReturnUserName, pName, Reason,warnings);
Where are you getting 'warnings' from? replace this with:

pawn Код:
format(str,sizeof(str),"ADMIN: %s has been warned by Administrator %s [Reason: %s] (%d/3)",ReturnUserName, pName, Reason, PlayerInfo[playerid][Warnings]);
Same with the other formatted string.
Reply
#3

It change nothing cause it still shows me 3 warnings but I only give 1 warning.
And it still donґt kick when it reach 3 warnings.
What to do?

Reply
#4

Код:
dcmd_warn(playerid,params[])
{
	new year, month, day; getdate(year, month, day);
	new hour, minute, second; gettime(hour, minute, second);
	new ReturnPlayer, pName[24], ReturnUserName[24], str[128], Reason[128], string[256];
	{
 	if(PlayerInfo[playerid][AdminLevel] < 1) return false;
 	if(sscanf(params,"ds",ReturnPlayer,Reason)) return SendClientMessage(playerid, COLOR_WHITE,"USAGE: /warn [playerid] [reason]");
	if (!IsPlayerConnected(ReturnPlayer)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "Invalid playerID!");
	GetPlayerName(playerid, pName, sizeof(pName));
	GetPlayerName(ReturnPlayer, ReturnUserName, sizeof(ReturnUserName));
 	format(str,sizeof(str),"ADMIN: %s has been warned by Administrator %s [Reason: %s] (%d/3)",ReturnUserName, pName, Reason,warnings);
	SendClientMessageToAll(COLOR_BRIGHTRED, str);
 	format(str,sizeof(str),"%s has been warned by Administrator %s [Reason: %s] (Warns: %d/3) (%d.%d.%d)",ReturnUserName, pName, Reason,warnings, year, month, day);
	format(str, sizeof(str), "ADMIN: %s (ID: %d) has warned %s (ID: %d) Reason: %s", pName, playerid, ReturnUserName, ReturnPlayer, Reason);
	SendAdminMsg(COLOR_WHITE, str);
 	return 1;
	}
	if(PlayerInfo[playerid][Warnings] >= 3)
	{

	new File:KickFile = fopen("logs/KickLog.txt", io_append);
	SendClientMessage(playerid, COLOR_BRIGHTRED, "You have been automatically kicked. Reason: (3 Warnings)");
	format(str, sizeof(str), "[Server] %s has been kicked by Administrator %s [Reason: 3 Warnings]", ReturnUserName, pName);
	format(str,sizeof(str),"[Server] %s has been kicked by Administrator %s [Reason: 3 Warnings] (%d.%d.%d || %d:%d:%d)",ReturnUserName, pName, year, month, day);
	fwrite(KickFile, string);
	fclose(KickFile);
	}
	return 1;
}
Reply
#5

Quote:
Originally Posted by [TLV
ReVo_ ]
Код:
dcmd_warn(playerid,params[])
{
	new year, month, day; getdate(year, month, day);
	new hour, minute, second; gettime(hour, minute, second);
	new ReturnPlayer, pName[24], ReturnUserName[24], str[128], Reason[128], string[256];
	{
 	if(PlayerInfo[playerid][AdminLevel] < 1) return false;
 	if(sscanf(params,"ds",ReturnPlayer,Reason)) return SendClientMessage(playerid, COLOR_WHITE,"USAGE: /warn [playerid] [reason]");
	if (!IsPlayerConnected(ReturnPlayer)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "Invalid playerID!");
	GetPlayerName(playerid, pName, sizeof(pName));
	GetPlayerName(ReturnPlayer, ReturnUserName, sizeof(ReturnUserName));
 	format(str,sizeof(str),"ADMIN: %s has been warned by Administrator %s [Reason: %s] (%d/3)",ReturnUserName, pName, Reason,warnings);
	SendClientMessageToAll(COLOR_BRIGHTRED, str);
 	format(str,sizeof(str),"%s has been warned by Administrator %s [Reason: %s] (Warns: %d/3) (%d.%d.%d)",ReturnUserName, pName, Reason,warnings, year, month, day);
	format(str, sizeof(str), "ADMIN: %s (ID: %d) has warned %s (ID: %d) Reason: %s", pName, playerid, ReturnUserName, ReturnPlayer, Reason);
	SendAdminMsg(COLOR_WHITE, str);
 	return 1;
	}
	if(PlayerInfo[playerid][Warnings] >= 3)
	{

	new File:KickFile = fopen("logs/KickLog.txt", io_append);
	SendClientMessage(playerid, COLOR_BRIGHTRED, "You have been automatically kicked. Reason: (3 Warnings)");
	format(str, sizeof(str), "[Server] %s has been kicked by Administrator %s [Reason: 3 Warnings]", ReturnUserName, pName);
	format(str,sizeof(str),"[Server] %s has been kicked by Administrator %s [Reason: 3 Warnings] (%d.%d.%d || %d:%d:%d)",ReturnUserName, pName, year, month, day);
	fwrite(KickFile, string);
	fclose(KickFile);
	}
	return 1;
}
This really donґt help xDDD

I still have the same problems.

and a warning too:

\Adminscript.pwn(1223) : warning 225: unreachable code

This line: if(PlayerInfo[playerid][Warnings] == 3)
Reply
#6

Exactly where do you set the warns + 1?
Reply
#7

Quote:
Originally Posted by [jS
Infinity ]
Exactly where do you set the warns + 1?
This is my problem I donґt really know how to set this.

Reply
#8

So, I need it quickly.
Could someone post a solution or something?

I get an error at this line:

if(PlayerInfo[playerid][Warnings] == 3)

ERROR: \Adminscript.pwn(1223) : warning 225: unreachable code

Like Infinity said I need something where I set when I get +1 warn. When it reach 3 warn it kicks the player automatically. How to do that Need it quickly ;/
Reply
#9

Where did you get this command from? It uses an external variable (warnings) to calculate the warnings that a player has.
Reply
#10

From here: http://forum.sa-mp.com/index.php?topic=91395.0

;/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)