OnPlayerStateChange - 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)
+--- Thread: OnPlayerStateChange (
/showthread.php?tid=459015)
OnPlayerStateChange -
Ananisiki - 19.08.2013
^^^^^^^^
Re: OnPlayerStateChange -
Vanter - 19.08.2013
AdminCar[playerid]
Re: OnPlayerStateChange -
Pasa - 19.08.2013
When you put arrays you must use index it
Код:
defining
new WHATEVER[NUMBER_OF_SLOTS] //MAX_VEHICLES i think it is 2000
storing variables in the array:
WHATEVER[0] = CreateVehicle(..); //THE ARRAY SLOT 0
WHATEVER[1] = CreateVehicle(..); //THE ARRAY SLOT 0
WHATEVER[2] = CreateVehicle(..); //THE ARRAY SLOT 0
//note: do not cross the limit when you storing the data (the array id must be lover for 1 of the number of slots in the array), in this case the "NUMBER_OF_SLOTS" is 3 - 3 slots;
checking:
if(GetPlayerVehicleID(playerid) == WHATEVER[THE_ARRAY_ID_TO_CHECK_THE_DATA_THAT-IS_STORED_IN_THE_ARRAY_ID])
Re: OnPlayerStateChange -
Ananisiki - 19.08.2013
^^^^^^^^
Re: OnPlayerStateChange -
Ananisiki - 20.08.2013
Bump
Re: OnPlayerStateChange -
nor15 - 20.08.2013
AdminCar; not AdminCar[MAX_PLAYERS];
Re: OnPlayerStateChange -
Youarex - 20.08.2013
Assuming there are more than one admin vehicles.
pawn Код:
#define MAX_ADMIN_VEHICLES 3
new AdminCar[MAX_ADMIN_VEHICLES];
pawn Код:
public OnFilterScriptInit()
{
AdminCar[0] = CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay);
AdminCar[1] = CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay);
AdminCar[2] = CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay);
return 1;
}
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER && IsAdminVehicle(GetPlayerVehicleID(playerid)))
{
if(!IsCnRAdmin(playerid))
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, 0x281aeb, "This vehicle doesn't belong to you.");
}
}
return 1;
}
pawn Код:
IsAdminVehicle(vehicleid)
{
for(new i; i < MAX_ADMIN_VEHICLES; i++)
{
if(vehicleid == AdminCar[i])
{
return true;
}
}
return false;
}
Re: OnPlayerStateChange -
xganyx - 21.08.2013
Use this
pawn Код:
#include <a_samp>
new AdminCar[3];
enum PlayerInfo
{
Admin
}
new PlayerData[MAX_PLAYERS][PlayerInfo];
public OnFilterScriptInit()
{
AdminCar[0] = CreateVehicle(...);
AdminCar[1] = CreateVehicle(...);
AdminCar[2] = CreateVehicle(...);
return 1;
}
public OnPlayerEnterVehicle(playerid,vehicleid,ispassenger)
{
if(PlayerData[playerid][Admin] == 0)
{
for(new i; i < sizeof(AdminCar); i++)
{
if(GetPlayerVehicleID(playerid) == i)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, 0x281aeb, "This vehicle doesn't belong to ");
}
}
}
return 1;
}