banning a player crashes the server? (custom ban)
#1

pawn Код:
forward SafeBan(playerid,reason[],days);
public SafeBan(playerid,reason[],days)
{
    printf("Banning A Player:%s(%d)",Playername(playerid),playerid);
    for(new i=0;i<MAX_VEHICLES;i++)
    {
        if(strmatch(VehicleSystem[i][Owner],Playername(playerid)))
        {
            printf("Deleting His Vehicles:%s(%d)",Playername(playerid),playerid);
            new string[128];
            VehicleSystem[IsBuyableCar[i]][Locked]=0;

            new Escape[1][MAX_PLAYER_NAME];
            strmid(VehicleSystem[IsBuyableCar[i]][Owner],"Unbought",0,23,MAX_PLAYER_NAME);
            mysql_real_escape_string(VehicleSystem[IsBuyableCar[i]][Owner], Escape[0]);

            format(GlobalQuery,sizeof(GlobalQuery),"UPDATE `Vehicles` SET `Owner`='%s',`Locked`=%d WHERE CarID = %d",Escape[0],0,VehicleSystem[IsBuyableCar[i]][CarID]);
            print(GlobalQuery);
            mysql_query(GlobalQuery);
            break;
        }
    }
    for(new h=0; h<MAX_HOUSES; h++)
    {
        if(strmatch(HouseInfo[h][Owner],Playername(playerid)))
        {
            printf("Deleting His Houses:%s(%d)",Playername(playerid),playerid);
            new hEscape1[3][MAX_PLAYER_NAME];
            mysql_real_escape_string(HouseInfo[h][HouseName],hEscape1[0]);
            mysql_real_escape_string(HouseInfo[h][Renter], hEscape1[1]);
            strmid(HouseInfo[h][Owner],"Unbought",0,23,MAX_PLAYER_NAME+1);
            mysql_real_escape_string(HouseInfo[h][Owner], hEscape1[2]);

            strmid(hEscape1[0],"Nothing",0,34,35);
            strmid(hEscape1[1],"Nobody",0,23,MAX_PLAYER_NAME);

            HouseInfo[h][Owned] = 0;
            HasHouse[playerid] -= 1;
            HouseInfo[h][RentPrice] = 0;
            HouseInfo[h][Rentable] = 0;
            HouseInfo[h][Locked]=0;
            printf("Deleting His Houses2:%s(%d)",Playername(playerid),playerid);
            DestroyDynamicMapIcon(HouseInfo[h][Icon]);
            Delete3DTextLabel(HouseInfo[h][HLabel]);

            new Location[MAX_ZONE_NAME];
            Get2DZone(Location, HouseInfo[h][PickupX],HouseInfo[h][PickupY],HouseInfo[h][PickupZ]);
            format(string,sizeof(string),"[House for sale]\nAddress: %d / %s\nPrice: $%d ",HouseInfo[h][Houseid],Location,HouseInfo[h][Price]);
            HouseInfo[h][HLabel] =  Create3DTextLabel(string, LIME, HouseInfo[h][PickupX],HouseInfo[h][PickupY],HouseInfo[h][PickupZ] + 0.30, 30.0, 0, 1);
            HouseInfo[h][Icon] = CreateDynamicMapIcon(HouseInfo[h][PickupX],HouseInfo[h][PickupY],HouseInfo[h][PickupZ], 31, 1,-1, -1,-1,30.0);
            printf("Deleting His Houses3:%s(%d)",Playername(playerid),playerid);
            format(GlobalQuery,sizeof(GlobalQuery),"UPDATE `Houses` SET `HouseName`='%s',`Owner`='%s', `Owned`=%d,`Locked`=%d,`Renter`='%s',`Rentable`=%d,`RentPrice`=%d ,`RentVault`=%d  WHERE Houseid = %d",hEscape1[0],hEscape1[2],0,0,hEscape1[1],0,0,0,h);
            print(GlobalQuery);
            mysql_query(GlobalQuery);
            printf("Deleting His Houses Finished:%s(%d)",Playername(playerid),playerid);
            break;
        }
    }
    printf("Banning Him0:%s(%d)",Playername(playerid),playerid);
    new ip[16];
    GetPlayerIp(playerid,ip,sizeof ip);
    new year,mon,d;
    getdate(year,mon,d);
    new s = GetTempBanSlot();
    TempBans[s][BannedName] = Playername(playerid);
    TempBans[s][BannedIP] = ip;
    TempBans[s][UnbanDate] = d+days;
    TempBans[s][Banid] = Bancount+1;
    format(TempBans[s][Reason],150,"%s",reason);
    printf("Banning Him1:%s(%d)",Playername(playerid),playerid);
    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;
    }
    printf("Banning Him2:%s(%d)",Playername(playerid),playerid);
    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,mon,TempBans[s][UnbanDate],year);
    MessageToAdmins(COLOR_ADMIN,str);
    new query[256],bEscape[3][80];
    mysql_real_escape_string(TempBans[s][BannedName],bEscape[0]);
    mysql_real_escape_string(TempBans[s][BannedIP],bEscape[1]);
    mysql_real_escape_string(TempBans[s][Reason],bEscape[2]);
    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]);
    mysql_query(query);
    printf("Banning Him3:%s(%d)",Playername(playerid),playerid);
    format(str,sizeof str,"banip %s %s",ip,reason);
    SendRconCommand(str);
    SaveTempBans();
    printf("Banning Him4:%s(%d)",Playername(playerid),playerid);
    return 1;
}
it nvr prints baning him,
Reply


Messages In This Thread
banning a player crashes the server? (custom ban) - by The_Gangstas - 01.12.2010, 22:28
Re: banning a player crashes the server? (custom ban) - by Memoryz - 01.12.2010, 23:17
Re: banning a player crashes the server? (custom ban) - by The_Gangstas - 02.12.2010, 19:10
Re: banning a player crashes the server? (custom ban) - by The_Gangstas - 03.12.2010, 20:13

Forum Jump:


Users browsing this thread: 1 Guest(s)