Setting a 3 limit counter then kicking the player...
#1

Hey guys, so in my last post i wanted to restrict a vehicle for normal players (make it vip only)
Previous thread:https://sampforum.blast.hk/showthread.php?pid=4084044#pid4084044
And my solution was this.

Код:
//OnPlayerStateChange 
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 425 && User[playerid][accountVIP] == 0)
  {
         {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid, -1, "Hunter can only be used by VIP players.");
	   return 1;
          }
   }
Well now, i'm trying to set a 3 warning/limit thingy for normal players.
If they try to enter a vip vehicle and try that 3 times they will get warned & kicked from the server.


I tried setting up a counter then kick(playerid) if the counter reaches 3 but somehow it either kicks every single player from the server or the vip player that spawned the vehicle. pretty weird.
Any ideas?

Thank you.
Reply
#2

PHP код:
new warnings[MAX_PLAYERS];

public 
OnPlayerConnect(playerid)
{
    
warnings[playerid] = 0;
    return 
1;
}

//OnPlayerStateChange
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 425 && User[playerid][accountVIP] == 0)
{
    
warnings[playerid] ++;
    if(
warnings[playerid] > 2Kick(playerid);
    
RemovePlayerFromVehicle(playerid);
    
SendClientMessage(playerid, -1"Hunter can only be used by VIP players.");

Reply
#3

Quote:
Originally Posted by Kasichok
Посмотреть сообщение
PHP код:
new warnings[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
    
warnings[playerid] = 0;
    return 
1;
}
//OnPlayerStateChange
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 425 && User[playerid][accountVIP] == 0)
{
    
warnings[playerid] ++;
    if(
warnings[playerid] > 2Kick(playerid);
    
RemovePlayerFromVehicle(playerid);
    
SendClientMessage(playerid, -1"Hunter can only be used by VIP players.");

Just tried, this is what i want but it doesn't seem to work, as soon as i try to enter hunter the function with loop giving instantly 3 warnings resulting in a kick.

Also how can i make it to SendClientMessage everytime the said players gets a warning, ex:
"Hunter can only be used by VIP Players, Warning 1/3"

I'm sorry my syntax is really bad...



Edit:Fixed the loop, had to add return 1... I only need to get the SendClientMessage to properly display warnings before kicking the player. Also not sure if this has to do anything with "OnPlayerStateChange" but when i enter and leave vehicles the game will freeze for a second or two.
Reply
#4

PHP код:
//OnPlayerStateChange
new str[15];
    
warnings[playerid] ++;
    
format(str15"%d/3 warnings"warnings[playerid]);
    if(
warnings[playerid] > 2) { SetTimerEx("PKick"100false"d"playerid); Kick(playerid); }
    
RemovePlayerFromVehicle(playerid);
    
SendClientMessage(playerid, -1"Hunter can only be used by VIP players.");
 
///////////////////////////////////////////////////////////////////////////////////////////
forward PKick(playerid);
public 
PKick(playerid)
{
    
Kick(playerid);
    return 
1;

Reply
#5

Quote:
Originally Posted by Kasichok
Посмотреть сообщение
PHP код:
//OnPlayerStateChange
new str[15];
    
warnings[playerid] ++;
    
format(str15"%d/3 warnings"warnings[playerid]);
    if(
warnings[playerid] > 2) { SetTimerEx("PKick"100false"d"playerid); Kick(playerid); }
    
RemovePlayerFromVehicle(playerid);
    
SendClientMessage(playerid, -1"Hunter can only be used by VIP players.");
 
///////////////////////////////////////////////////////////////////////////////////////////
forward PKick(playerid);
public 
PKick(playerid)
{
    
Kick(playerid);
    return 
1;

Seems to work pretty well, the only issue now is the "%d/ 3 warnings"
It doesn't display anything.

Thanks a ton though for trying to help me. rep+!
Reply
#6

my bad

after
PHP код:
format(str15"%d/3 warnings"warnings[playerid]); 
add
PHP код:
SendClientMessage(playeridcolorstr); 
Reply
#7

Quote:
Originally Posted by Kasichok
Посмотреть сообщение
PHP код:
//OnPlayerStateChange
new str[15];
    
warnings[playerid] ++;
    
format(str15"%d/3 warnings"warnings[playerid]);
    if(
warnings[playerid] > 2) { SetTimerEx("PKick"100false"d"playerid); Kick(playerid); }
    
RemovePlayerFromVehicle(playerid);
    
SendClientMessage(playerid, -1"Hunter can only be used by VIP players.");
 
///////////////////////////////////////////////////////////////////////////////////////////
forward PKick(playerid);
public 
PKick(playerid)
{
    
Kick(playerid);
    return 
1;

If you're adding a timer it's not for nothing, why are you still calling Kick function directly inside the if statement?
Reply
#8

Quote:
Originally Posted by TheToretto
Посмотреть сообщение
If you're adding a timer it's not for nothing, why are you still calling Kick function directly inside the if statement?
Cause then the message wont be displayed
Reply
#9

Quote:
Originally Posted by Kasichok
Посмотреть сообщение
Cause then the message wont be displayed
That's the point of your timer. But you still call the function Kick right after SetTimerEx...
Reply
#10

Quote:
Originally Posted by TheToretto
Посмотреть сообщение
That's the point of your timer. But you still call the function Kick right after SetTimerEx...
ohh true i forgot to delete it after i added the message
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)