how i remove this errors ?
#1

I am put and temp ban system in my gamemode but when i compiled it it gave me error


Errors type:
(819) : error 017: undefined symbol "TempBanData"
(819) : error 009: invalid array size (negative, zero or out of bounds)
(4644) : error 021: symbol already defined: "name"

Errors lines :
1:new TempBans[24][TempBanData]; // 24 = max bans

2:
//temp Ban checking
new name[24],ip[16];
GetPlayerIp(playerid,ip,sizeof ip);
GetPlayerName(playerid,name,sizeof name);
for(new id; id < 24; id++)
{
if(!strcmp(name,TempBans[id][BannedName]))
{ // ban type is name
SendClientMessage(playerid,COLOR_RED,"Your ban has not expired!");
Kick(playerid);
return 1;
}

if(!strcmp(ip,TempBans[id][BannedIP]))
{ // ban type is ip !
SendClientMessage(playerid,COLOR_RED,"Your ban has not expired!");
Kick(playerid);
return 1;
}
}
Reply
#2

Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>

#define COLOR_RED 0xFF0000AA

enum TempBanData
{
BannedName[24],
BannedIP[16],
UnbanDate
}

new TempBans[24][TempBanData]; // 24 = max bans

public OnFilterScriptInit()
{
LoadTempBans();
TempBanUpdate();
print("Temporary Ban System Loaded...");
return 1;
}

public OnFilterScriptExit()
{
SaveTempBans();
return 1;
}

CMD:tempbanip(playerid,params[])
{
if(!TempAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"You must be admin to use this command.");
new ip[16],days;
if(GetCurrentTempBanCount() == 24) return SendClientMessage(playerid,COLOR_RED,"Temp Ban Limit Reached.");
if(sscanf(params, "s[16]d",ip,days)) return SendClientMessage(playerid,COLOR_RED,"Usage: /tempbanip <ip> <amount of days ahead>");
new year,mon,d;
getdate(year,mon,d);
new i = GetTempBanSlot();
TempBans[i][BannedIP] = ip;
TempBans[i][UnbanDate] = d+days;
new str[100];
format(str,sizeof str,"** IP %s set to to unbanned on %d/%d/%d",mon,d+days,year);
SendClientMessage(playerid,COLOR_RED,str);
format(str,sizeof str,"banip %s",ip);
SendRconCommand(str);
return 1;
}

CMD:tbip(playerid,params[])
{
return cmd_tempbanip(playerid,params);
}

CMD:tbu(playerid,params[])
{
return cmd_tempbanname(playerid,params);
}

CMD:tb(playerid,params[])
{
return cmd_tempban(playerid,params);
}

CMD:tempbanname(playerid,params[])
{
if(!TempAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"You must be admin to use this command.");
new name[24],days;
if(GetCurrentTempBanCount() == 24) return SendClientMessage(playerid,COLOR_RED,"Temp Ban Limit Reached.");
if(sscanf(params, "s[24]d",name,days)) return SendClientMessage(playerid,COLOR_RED,"Usage: /tempbanname <Name> <amount of days ahead>");
new year,mon,d;
getdate(year,mon,d);
new i = GetTempBanSlot();
format(TempBans[i][BannedName],sizeof name,"%s",name);
TempBans[i][BannedName] = name;
TempBans[i][UnbanDate] = d+days;
new str[100];
format(str,sizeof str,"Name %s set to to unbanned on %d/%d/%d",mon,d+days,year);
SendClientMessage(playerid,COLOR_RED,str);
return 1;
}

CMD:tempban(playerid,params[])
{
if(!TempAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"You must be admin to use this command.");
new days,rsn[24],id,name[24];
if(GetCurrentTempBanCount() == 24) return SendClientMessage(playerid,COLOR_RED,"Temp Ban Limit Reached.");
if(sscanf(params, "uds[24]",id,days,rsn)) return SendClientMessage(playerid,COLOR_RED,"Usage: /tempban <PlayerID/Name> <Amount Of Days> <Reason>");
new year,mon,d;
getdate(year,mon,d);
new i = GetTempBanSlot();
new aname[24];
GetPlayerName(playerid,aname,sizeof aname);
GetPlayerName(id,name,sizeof name);
format(TempBans[i][BannedName],sizeof name,"%s",name);
TempBans[i][BannedName] = name;
TempBans[i][UnbanDate] = d+days;
new str[128];
GetPlayerName(id,name,sizeof name);
format(str,sizeof str,"%s (ID%d) has been temporary banned by Admin %s (ID:%d) (%s)",aname,playerid,name,id,rsn);
SendClientMessage(playerid,COLOR_RED,str);
return 1;
}

CMD:tempunban(playerid,params[])
{
if(!TempAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"You must be admin to use this command.");
new ip[16];
if(GetCurrentTempBanCount() == 24) return SendClientMessage(playerid,COLOR_RED,"Temp Ban Limit Reached.");
if(sscanf(params, "s[16]",ip)) return SendClientMessage(playerid,COLOR_RED,"Usage: /tempunban <IPAddress>");
new i = GetBan(ip);
if(i == 0) return SendClientMessage(playerid,COLOR_RED,"Ban Entry could not be found! Try again.");
new str[100];
format(str,sizeof str,"IP %s unbanned!",ip);
SendClientMessage(playerid,COLOR_RED,str);
DeleteTempBanEntry(i);
return 1;
}

public OnPlayerConnect(playerid)
{
new name[24],ip[16];
GetPlayerIp(playerid,ip,sizeof ip);
GetPlayerName(playerid,name,sizeof name);
for(new id; id < 24; id++)
{
if(!strcmp(name,TempBans[id][BannedName]))
{ // ban type is name
SendClientMessage(playerid,COLOR_RED,"Your ban has not expired!");
Kick(playerid);
return 1;
}

if(!strcmp(ip,TempBans[id][BannedIP]))
{ // ban type is ip !
SendClientMessage(playerid,COLOR_RED,"Your ban has not expired!");
Kick(playerid);
return 1;
}
}
return 1;
}

forward TempBanUpdate();
public TempBanUpdate()
{
new day,month,year,hour,minute,second,str[100];
gettime(hour,minute,second);
getdate(year,month,day);
for(new id; id < 24; id++)
{
if(TempBans[id][UnbanDate] == day) // type 1 = day ban (unban on specific day)
{
if(strlen(TempBans[id][BannedIP]) > 0)
{
format(str,sizeof str,"unbanip %s",TempBans[id][BannedIP]);
SendRconCommand(str);
format(str,sizeof str,"Auto-Unban: IP %s was unbanned. (Ban Expired)",TempBans[id][BannedIP]);
print(str);
DeleteTempBanEntry(id);
return 1;
}

if(strlen(TempBans[id][BannedName]) > 0)
{
format(str,sizeof str,"Auto-Unban: Name %s was unbanned. (Ban Expired)",TempBans[id][BannedName]);
print(str);
DeleteTempBanEntry(id);
}
}
}
return 1;
}

DeleteTempBanEntry(id)
{
strdel(TempBans[id][BannedName],0,24);
strdel(TempBans[id][BannedIP],0,16);
TempBans[id][UnbanDate] = 0;
}

GetCurrentTempBanCount()
{
new loaded;
for(new id; id < 24; id++) //max of 24 temporary bans
{
if(strlen(TempBans[id][BannedName]) > 0 || strlen(TempBans[id][BannedIP]) > 0) loaded++;
}
return loaded;
}

GetTempBanSlot()
{
new loaded;
for(new id; id < 24; id++) //max of 24 temporary bans
{
if(strlen(TempBans[id][BannedName]) == 0 || strlen(TempBans[id][BannedIP]) == 0) loaded = id;
}
return loaded;
}

stock SaveTempBans()
{
new dat[100];
new File: file = fopen("tempbans.txt", io_write);
for(new id; id<24; id++)
{
format(dat, 100, "%s,%s,%d\r\n",TempBans[id][BannedName],TempBans[id][BannedIP],TempBans[id][UnbanDate]);
fwrite(file, dat);
}
fclose(file);
}

LoadTempBans()
{
// load the bans
new loaded=0;
if(fexist("tempbans.txt"))
{
new dat[100];
new File: file = fopen("tempbans.txt", io_read);
if (file)
{
for(new id; id < 24; id++) //max of 24 temporary bans
{
fread(file,dat);
sscanf(dat,"p<,>s[24]s[16]d",TempBans[id][BannedName],TempBans[id][BannedIP],TempBans[id][UnbanDate]);
if(strlen(TempBans[id][BannedName]) > 0) loaded++;
}
fclose(file);
}
}
return 1;
}

GetBan(ip[])
{
for(new id; id < 24; id++)
{
if(!strcmp(ip,TempBans[id][BannedIP]))
{
return id;
}
}
return 0;
}

stock TempAdmin(playerid)
{
if(IsPlayerAdmin(playerid)) return true;
return false;
}
Reply
#3

what is this
Reply
#4

Try this and save in filterscripts

Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>

#define COLOR_RED 0xFF0000AA

enum TempBanData
{
BannedName[24],
BannedIP[16],
UnbanDate
}

new TempBans[24][TempBanData]; // 24 = max bans

public OnFilterScriptInit()
{
LoadTempBans();
TempBanUpdate();
print("Temporary Ban System Loaded...");
return 1;
}

public OnFilterScriptExit()
{
SaveTempBans();
return 1;
}

CMD:tempbanip(playerid,params[])
{
if(!TempAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"You must be admin to use this command.");
new ip[16],days;
if(GetCurrentTempBanCount() == 24) return SendClientMessage(playerid,COLOR_RED,"Temp Ban Limit Reached.");
if(sscanf(params, "s[16]d",ip,days)) return SendClientMessage(playerid,COLOR_RED,"Usage: /tempbanip <ip> <amount of days ahead>");
new year,mon,d;
getdate(year,mon,d);
new i = GetTempBanSlot();
TempBans[i][BannedIP] = ip;
TempBans[i][UnbanDate] = d+days;
new str[100];
format(str,sizeof str,"** IP %s set to to unbanned on %d/%d/%d",mon,d+days,year);
SendClientMessage(playerid,COLOR_RED,str);
format(str,sizeof str,"banip %s",ip);
SendRconCommand(str);
return 1;
}

CMD:tbip(playerid,params[])
{
return cmd_tempbanip(playerid,params);
}

CMD:tbu(playerid,params[])
{
return cmd_tempbanname(playerid,params);
}

CMD:tb(playerid,params[])
{
return cmd_tempban(playerid,params);
}

CMD:tempbanname(playerid,params[])
{
if(!TempAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"You must be admin to use this command.");
new name[24],days;
if(GetCurrentTempBanCount() == 24) return SendClientMessage(playerid,COLOR_RED,"Temp Ban Limit Reached.");
if(sscanf(params, "s[24]d",name,days)) return SendClientMessage(playerid,COLOR_RED,"Usage: /tempbanname <Name> <amount of days ahead>");
new year,mon,d;
getdate(year,mon,d);
new i = GetTempBanSlot();
format(TempBans[i][BannedName],sizeof name,"%s",name);
TempBans[i][BannedName] = name;
TempBans[i][UnbanDate] = d+days;
new str[100];
format(str,sizeof str,"Name %s set to to unbanned on %d/%d/%d",mon,d+days,year);
SendClientMessage(playerid,COLOR_RED,str);
return 1;
}

CMD:tempban(playerid,params[])
{
if(!TempAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"You must be admin to use this command.");
new days,rsn[24],id,name[24];
if(GetCurrentTempBanCount() == 24) return SendClientMessage(playerid,COLOR_RED,"Temp Ban Limit Reached.");
if(sscanf(params, "uds[24]",id,days,rsn)) return SendClientMessage(playerid,COLOR_RED,"Usage: /tempban <PlayerID/Name> <Amount Of Days> <Reason>");
new year,mon,d;
getdate(year,mon,d);
new i = GetTempBanSlot();
new aname[24];
GetPlayerName(playerid,aname,sizeof aname);
GetPlayerName(id,name,sizeof name);
format(TempBans[i][BannedName],sizeof name,"%s",name);
TempBans[i][BannedName] = name;
TempBans[i][UnbanDate] = d+days;
new str[128];
GetPlayerName(id,name,sizeof name);
format(str,sizeof str,"%s (ID%d) has been temporary banned by Admin %s (ID:%d) (%s)",aname,playerid,name,id,rsn);
SendClientMessage(playerid,COLOR_RED,str);
return 1;
}

CMD:tempunban(playerid,params[])
{
if(!TempAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"You must be admin to use this command.");
new ip[16];
if(GetCurrentTempBanCount() == 24) return SendClientMessage(playerid,COLOR_RED,"Temp Ban Limit Reached.");
if(sscanf(params, "s[16]",ip)) return SendClientMessage(playerid,COLOR_RED,"Usage: /tempunban <IPAddress>");
new i = GetBan(ip);
if(i == 0) return SendClientMessage(playerid,COLOR_RED,"Ban Entry could not be found! Try again.");
new str[100];
format(str,sizeof str,"IP %s unbanned!",ip);
SendClientMessage(playerid,COLOR_RED,str);
DeleteTempBanEntry(i);
return 1;
}

public OnPlayerConnect(playerid)
{
new name[24],ip[16];
GetPlayerIp(playerid,ip,sizeof ip);
GetPlayerName(playerid,name,sizeof name);
for(new id; id < 24; id++)
{
if(!strcmp(name,TempBans[id][BannedName]))
{ // ban type is name
SendClientMessage(playerid,COLOR_RED,"Your ban has not expired!");
Kick(playerid);
return 1;
}

if(!strcmp(ip,TempBans[id][BannedIP]))
{ // ban type is ip !
SendClientMessage(playerid,COLOR_RED,"Your ban has not expired!");
Kick(playerid);
return 1;
}
}
return 1;
}

forward TempBanUpdate();
public TempBanUpdate()
{
new day,month,year,hour,minute,second,str[100];
gettime(hour,minute,second);
getdate(year,month,day);
for(new id; id < 24; id++)
{
if(TempBans[id][UnbanDate] == day) // type 1 = day ban (unban on specific day)
{
if(strlen(TempBans[id][BannedIP]) > 0)
{
format(str,sizeof str,"unbanip %s",TempBans[id][BannedIP]);
SendRconCommand(str);
format(str,sizeof str,"Auto-Unban: IP %s was unbanned. (Ban Expired)",TempBans[id][BannedIP]);
print(str);
DeleteTempBanEntry(id);
return 1;
}

if(strlen(TempBans[id][BannedName]) > 0)
{
format(str,sizeof str,"Auto-Unban: Name %s was unbanned. (Ban Expired)",TempBans[id][BannedName]);
print(str);
DeleteTempBanEntry(id);
}
}
}
return 1;
}

DeleteTempBanEntry(id)
{
strdel(TempBans[id][BannedName],0,24);
strdel(TempBans[id][BannedIP],0,16);
TempBans[id][UnbanDate] = 0;
}

GetCurrentTempBanCount()
{
new loaded;
for(new id; id < 24; id++) //max of 24 temporary bans
{
if(strlen(TempBans[id][BannedName]) > 0 || strlen(TempBans[id][BannedIP]) > 0) loaded++;
}
return loaded;
}

GetTempBanSlot()
{
new loaded;
for(new id; id < 24; id++) //max of 24 temporary bans
{
if(strlen(TempBans[id][BannedName]) == 0 || strlen(TempBans[id][BannedIP]) == 0) loaded = id;
}
return loaded;
}

stock SaveTempBans()
{
new dat[100];
new File: file = fopen("tempbans.txt", io_write);
for(new id; id<24; id++)
{
format(dat, 100, "%s,%s,%d\r\n",TempBans[id][BannedName],TempBans[id][BannedIP],TempBans[id][UnbanDate]);
fwrite(file, dat);
}
fclose(file);
}

LoadTempBans()
{
// load the bans
new loaded=0;
if(fexist("tempbans.txt"))
{
new dat[100];
new File: file = fopen("tempbans.txt", io_read);
if (file)
{
for(new id; id < 24; id++) //max of 24 temporary bans
{
fread(file,dat);
sscanf(dat,"p<,>s[24]s[16]d",TempBans[id][BannedName],TempBans[id][BannedIP],TempBans[id][UnbanDate]);
if(strlen(TempBans[id][BannedName]) > 0) loaded++;
}
fclose(file);
}
}
return 1;
}

GetBan(ip[])
{
for(new id; id < 24; id++)
{
if(!strcmp(ip,TempBans[id][BannedIP]))
{
return id;
}
}
return 0;
}

stock TempAdmin(playerid)
{
if(IsPlayerAdmin(playerid)) return true;
return false;
}
or

add

enum TempBanData
{
BannedName[24],
BannedIP[16],
UnbanDate
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)