Setting a 3 limit counter then kicking the player... -
alexjanjaj - 19.02.2019
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.
Re: Setting a 3 limit counter then kicking the player... -
Kasichok - 19.02.2019
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] > 2) Kick(playerid);
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, -1, "Hunter can only be used by VIP players.");
}
Re: Setting a 3 limit counter then kicking the player... -
alexjanjaj - 19.02.2019
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] > 2) Kick(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.
Re: Setting a 3 limit counter then kicking the player... -
Kasichok - 19.02.2019
PHP код:
//OnPlayerStateChange
new str[15];
warnings[playerid] ++;
format(str, 15, "%d/3 warnings", warnings[playerid]);
if(warnings[playerid] > 2) { SetTimerEx("PKick", 100, false, "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;
}
Re: Setting a 3 limit counter then kicking the player... -
alexjanjaj - 19.02.2019
Quote:
Originally Posted by Kasichok
PHP код:
//OnPlayerStateChange
new str[15];
warnings[playerid] ++;
format(str, 15, "%d/3 warnings", warnings[playerid]);
if(warnings[playerid] > 2) { SetTimerEx("PKick", 100, false, "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+!
Re: Setting a 3 limit counter then kicking the player... -
Kasichok - 19.02.2019
my bad
after
PHP код:
format(str, 15, "%d/3 warnings", warnings[playerid]);
add
PHP код:
SendClientMessage(playerid, color, str);
Re: Setting a 3 limit counter then kicking the player... -
TheToretto - 19.02.2019
Quote:
Originally Posted by Kasichok
PHP код:
//OnPlayerStateChange
new str[15];
warnings[playerid] ++;
format(str, 15, "%d/3 warnings", warnings[playerid]);
if(warnings[playerid] > 2) { SetTimerEx("PKick", 100, false, "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?
Re: Setting a 3 limit counter then kicking the player... -
Kasichok - 19.02.2019
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
Re: Setting a 3 limit counter then kicking the player... -
TheToretto - 19.02.2019
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...
Re: Setting a 3 limit counter then kicking the player... -
Kasichok - 19.02.2019
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