[Solved]Thnx To Mansonh! - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Solved]Thnx To Mansonh! (
/showthread.php?tid=126345)
[Solved]Thnx To Mansonh! -
hvampire - 08.02.2010
ok i added a system in my gamemode that player can only enter hydras and rustlers but problem is : when i put the code in the gamemode script , it blocks all players (it set to block players and allow admins) and if putted in admin script , it does nothing , here is the code :::
Код:
//==============================================================================
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(PlayerInfo[playerid][Level] < 1)
{
new vehicleid = GetPlayerVehicleID(playerid);
new modelid = GetVehicleModel(vehicleid);
if(newkeys == 2 || newkeys == 3)
{
if(modelid != 476 && modelid != 520)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,0xFF9900AA, "This vehicle is not allowed!");
}
}
}
return 1;
}
Re: help? -
mansonh - 08.02.2010
Just checking, you want players to be able to use only these two, or you don't want them to be able to?
Try putting in a few printf statements to check if your admin is set correctly.
Код:
//==============================================================================
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
printf("player(%d), level set to %d", playerid, PlayerInfo[playerid][Level]);
if(PlayerInfo[playerid][Level] < 1)
{
print("Player is not an admin");
new vehicleid = GetPlayerVehicleID(playerid);
new modelid = GetVehicleModel(vehicleid);
if(modelid != 476 && modelid != 520)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,0xFF9900AA, "This vehicle is not allowed!");
}
}
return 1;
}
Although I am not sure why you are doing it on keystate, seems a waste to have this check every time they press a key when you can just do it under onplayerstatechange.
Here is the code that will kick non admins out of hydras or rustlers.
Код:
//==============================================================================
public OnPlayerStateChange(playerid, newstate, oldstate)
{
printf("player(%d), level set to %d", playerid, PlayerInfo[playerid][Level]);
if(newstate==PLAYER_STATE_DRIVER && PlayerInfo[playerid][Level] < 1)
{
print("Player is not an admin");
new vehicleid = GetPlayerVehicleID(playerid);
new modelid = GetVehicleModel(vehicleid);
if(newkeys == 2 || newkeys == 3)
{
if(modelid == 476 || modelid == 520)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,0xFF9900AA, "This vehicle is not allowed!");
}
}
}
return 1;
}
Re: help? -
hvampire - 08.02.2010
i want when a non-admin player gets in a vehicle (exept rustlers and hydras) it kick him out of vehicle but when i put function on gamemode it kick everyone , if putted in ladmin it doesnt work