Skipping SendClientMessage
#1

I got a ban function that does EVERYTHING except sends the client message. Wtf?

pawn Код:
public DynBan(playerid,days,reason[])
{
    new IP[16];
    GetPlayerIp(playerid, IP, sizeof(IP));
    new Query[200];
    new BanTime = days * 86400;
    new FinalBanTime = gettime() + BanTime;
    format(Query,sizeof(Query),"INSERT INTO `bans` (`username`,`ip`,`reason`,`time`) VALUES ('%s','%s','%s','%i')",PlayerName(playerid),IP,reason,FinalBanTime);
    mysql_query(Query);
    new String[200];
    format(String,sizeof(String),"You have been banned for %i days for %s!",days,reason);
    SendClientMessage(playerid,COLOR_RED,String);
    Kick(playerid);
    return 1;
}
Reply
#2

http://forum.sa-mp.com/showthread.ph...35#post2438435
Reply
#3

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
So basically i have to delay it.
Reply
#4

or you could make it so it will send the msg first and then by the time it gives the ban he might get the msg.
Reply
#5

Quote:
Originally Posted by Edix
Посмотреть сообщение
or you could make it so it will send the msg first and then by the time it gives the ban he might get the msg.
That wouldn't work, you need to set a timer.
Reply
#6

pawn Код:
public DynBan(playerid,days,reason[])
{
    new IP[16];
    GetPlayerIp(playerid, IP, sizeof(IP));
    new Query[200];
    new BanTime = days * 86400;
    new FinalBanTime = gettime() + BanTime;
    format(Query,sizeof(Query),"INSERT INTO `bans` (`username`,`ip`,`reason`,`time`) VALUES       ('%s','%s','%s','%i')",PlayerName(playerid),IP,reason,FinalBanTime);
    mysql_query(query);
    new String[200];
    format(String,sizeof(String),"You have been banned for %i days for %s!",days,reason);
    SendClientMessage(playerid,COLOR_RED,String);
    KickPlayer(playerid);
    return 1;
}

pawn Код:
stock KickPlayer(playerid)
{
    SetPVarInt(playerid, "PlayerKicked", 1);
    SetTimerEx("KickTimer", 5, false, "i", playerid);
    return 1;
}
Add this stock and the public below.

pawn Код:
forward KickTimer(playerid);
public KickTimer(playerid)
{
    Kick(playerid);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)