Problems with /warn asking for a return
#1

Whole Code:

Код:
dcmd_warn(playerid,params[])
{
  new str[128], reason[128];
  new giveplayerid;
  if(PlayerInfo[playerid][pAdmin] == 0) return SystemMsg(playerid, "You must be a admin to use this command!");
  if(sscanf(params, "us", giveplayerid, reason)) return SystemMsg(playerid, " Usage : /warn [playerid / name] [reason]");
  if(!IsPlayerConnected(giveplayerid)) return SystemMsg(playerid, "That player is not connected!");
  format(str, sizeof(str), "ADMIN %s has warned %s [Reason: %s]", PlayerName(playerid), PlayerName(giveplayerid), reason);
  SendClientMessageToAll(COLOR_RED, str); PlayerInfo[giveplayerid][pWarns]++; dUserSetINT(PlayerName(playerid)).("pWarns",PlayerInfo[playerid][pWarns]);
  	new str2[MAX_STRING], second, minute, hour, day, month, year;
  	gettime(hour, minute, second);
	getdate(year, month, day);
  format(str2, sizeof(str2), "ADMIN %s (%s) warned %s (%s) on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), GetIp(playerid), PlayerName(giveplayerid), GetIp(giveplayerid), month, day, year, hour, minute, second, reason);
  AdminLog(str2);
  if(PlayerInfo[playerid][pWarns] == 3)
  {
	PlayerInfo[playerid][pBanned] = 1;
	format(str, sizeof(str), "..: SERVER kicked %s. Reason: Reached 3 Warnings :..", PlayerName(playerid));
	SendClientMessageToAll(COLOR_RED, str);
  new str3[MAX_STRING];
  gettime(hour, minute, second);
  getdate(year, month, day);
  format(str3, sizeof(str3), "PLAYER %s (%s) got auto-banned on %d/%d/%d at %d:%d:%d. (Reason: 'Reached 3 Warnings')", PlayerName(playerid), GetIp(playerid), month, day, year, hour, minute, second);
  return 1; }}
Line Erroring:

return 1; }}

Error Code:

C:\Documents and Settings\EPRP (3).pwn(880) : warning 209: function "dcmd_warn" should return a value
Reply
#2

Use this:
pawn Код:
dcmd_warn(playerid,params[])
{
  new str[128], reason[128];
  new giveplayerid;
  if(PlayerInfo[playerid][pAdmin] == 0) return SystemMsg(playerid, "You must be a admin to use this command!");
  if(sscanf(params, "us", giveplayerid, reason)) return SystemMsg(playerid, " Usage : /warn [playerid / name] [reason]");
  if(!IsPlayerConnected(giveplayerid)) return SystemMsg(playerid, "That player is not connected!");
  format(str, sizeof(str), "ADMIN %s has warned %s [Reason: %s]", PlayerName(playerid), PlayerName(giveplayerid), reason);
  SendClientMessageToAll(COLOR_RED, str); PlayerInfo[giveplayerid][pWarns]++; dUserSetINT(PlayerName(playerid)).("pWarns",PlayerInfo[playerid][pWarns]);
  new str2[MAX_STRING], second, minute, hour, day, month, year;
  gettime(hour, minute, second);
  getdate(year, month, day);
  format(str2, sizeof(str2), "ADMIN %s (%s) warned %s (%s) on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), GetIp(playerid), PlayerName(giveplayerid), GetIp(giveplayerid), month, day, year, hour, minute, second, reason);
  AdminLog(str2);
  if(PlayerInfo[playerid][pWarns] == 3)
  {
    PlayerInfo[playerid][pBanned] = 1;
    format(str, sizeof(str), "..: SERVER kicked %s. Reason: Reached 3 Warnings :..", PlayerName(playerid));
    SendClientMessageToAll(COLOR_RED, str);
    new str3[MAX_STRING];
    gettime(hour, minute, second);
    getdate(year, month, day);
    format(str3, sizeof(str3), "PLAYER %s (%s) got auto-banned on %d/%d/%d at %d:%d:%d. (Reason: 'Reached 3 Warnings')", PlayerName(playerid), GetIp(playerid), month, day, year, hour, minute, second);
  }
  return 1;
}
Reply
#3

You've been a bit of a saint today, Thanks.
Reply
#4

For some reason it isnt banning me after 3 warns
Reply
#5

I don't see the Ban function in your code, is this it?
pawn Код:
PlayerInfo[playerid][pBanned] = 1;
And the timer checks if you're pBanned?
Reply
#6

You're checking if the admin has 3 warns, not the specified playerid.

pawn Код:
dcmd_warn(playerid,params[])
{
  new str[128], reason[128];
  new giveplayerid;
  if(PlayerInfo[playerid][pAdmin] == 0) return SystemMsg(playerid, "You must be a admin to use this command!");
  if(sscanf(params, "us", giveplayerid, reason)) return SystemMsg(playerid, " Usage : /warn [playerid / name] [reason]");
  if(!IsPlayerConnected(giveplayerid)) return SystemMsg(playerid, "That player is not connected!");
  format(str, sizeof(str), "ADMIN %s has warned %s [Reason: %s]", PlayerName(playerid), PlayerName(giveplayerid), reason);
  SendClientMessageToAll(COLOR_RED, str); PlayerInfo[giveplayerid][pWarns]++; dUserSetINT(PlayerName(playerid)).("pWarns",PlayerInfo[playerid][pWarns]);
  new str2[MAX_STRING], second, minute, hour, day, month, year;
  gettime(hour, minute, second);
  getdate(year, month, day);
  format(str2, sizeof(str2), "ADMIN %s (%s) warned %s (%s) on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), GetIp(playerid), PlayerName(giveplayerid), GetIp(giveplayerid), month, day, year, hour, minute, second, reason);
  AdminLog(str2);
  if(PlayerInfo[giveplayerid][pWarns] == 3)
  {
    PlayerInfo[giveplayerid][pBanned] = 1;
    format(str, sizeof(str), "..: SERVER kicked %s. Reason: Reached 3 Warnings :..", PlayerName(playerid));
    SendClientMessageToAll(COLOR_RED, str);
    new str3[MAX_STRING];
    gettime(hour, minute, second);
    getdate(year, month, day);
    format(str3, sizeof(str3), "PLAYER %s (%s) got auto-banned on %d/%d/%d at %d:%d:%d. (Reason: 'Reached 3 Warnings')", PlayerName(giveplayerid), GetIp(giveplayerid), month, day, year, hour, minute, second);
    Kick(giveplayerid); // or Ban().
  }
  return 1;
}
Reply
#7

Ah yes, Stupid stupid stupid error. Guess being new to Pawn you sometimes overlook things like that eh?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)