this code keeps repeating ifself 8 times if called once?
#1

pawn Код:
stock SafeBan(playerid,reason[],days)
{
    printf("Banning A Player:%s(%d)",Playername(playerid),playerid);
    new ip[16];
    GetPlayerIp(playerid,ip,sizeof ip);
    new year,mon,d;
    getdate(year,mon,d);
    new s = Bancount+1;
    format(TempBans[s][BannedName],24,"%s",Playername(playerid));
    format(TempBans[s][BannedIP],17,"%s",ip);
    TempBans[s][UnbanDate] = d+days;
    TempBans[s][Banid] = Bancount+1;
    Bancount++;
    format(TempBans[s][Reason],150,"%s",reason);
    switch(d)
    {
        case 20,21,22: TempBans[s][UnbanDate] = 26-days;
        case 23,24,25: TempBans[s][UnbanDate] = 27-days;
        case 26,27,28: TempBans[s][UnbanDate] = 28-days;
        case 29,30,31: TempBans[s][UnbanDate] = 31-days,mon+=1;
    }
    new str[100];
    format(str,sizeof str,"*Ban: %s(%d) Has Been Banned. Ban Date Set To Be Expired On %d/%d/%d",Playername(playerid),playerid,TempBans[s][UnbanDate],mon,year);
    MessageToAdmins(COLOR_ADMIN,str);
    new bEscape[3][80];
    mysql_real_escape_string(Playername(playerid),bEscape[0]);
    mysql_real_escape_string(ip,bEscape[1]);
    mysql_real_escape_string(reason,bEscape[2]);
    new Query[512];
    format(Query, sizeof(Query), "INSERT INTO `Bans` (`Banid`,`Name`,`IP`,`UnbanDate`,`Reason`) VALUES (%d,'%s','%s',%d,'%s')",TempBans[s][Banid],bEscape[0],bEscape[1],TempBans[s][UnbanDate],bEscape[2]);
    printf(Query);
    mysql_query(Query);
    /*format(str,sizeof str,"banip %s %s",ip,reason);
    SendRconCommand(str);*/

    //BanEx(playerid,reason);
    Kick(playerid);
    SaveTempBans();
    return 1;
}
it sends the query,the clientmessage, 8 times when a player is banned.
how i used it?
pawn Код:
format(string,sizeof(string),"Auto Advertising Ban(%s)",text);
        SafeBan(playerid,string,8);
Reply
#2

Код:
if (GetPVarInt(playerid,"BanInProgress">0){return 1;}else
{
SendClientMessageToAll(0xff0000ff,"called again");
//this line never should get executed. if so, this function gets called again while its still running..
}
SetPVarInt(playerid,"BanInProgress",1);
//your stuff here
SetPVarInt(playerid,"BanInProgress",0);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)