// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
new admincar;
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
#endif
public OnGameModeInit()
{
admincar = AddStaticVehicle(560,1520.1329,-1622.6709,13.2541,359.9984,17,1); // Sultan 1 >>>>>>>>>>>>>>>>>
admincar = AddStaticVehicle(560,1520.7255,-1609.5054,13.2505,358.1849,17,1); // Sultan 2 >>>>>>>>>>>>>>>>>
AddStaticVehicle(555,1515.0394,-1657.7910,13.2236,286.5503,58,1);
AddStaticVehicle(415,1517.4779,-1669.4038,13.5506,323.7956,25,1);
AddStaticVehicle(500,1561.2533,-1632.5758,13.5736,75.1998,40,84);
AddStaticVehicle(444,1514.9342,-1626.5626,14.3551,311.3241,32,53);
AddStaticVehicle(589,1535.6235,-1677.8708,13.0409,0.6939,31,31);
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerConnect(playerid)
{
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(admincar)
{
if(IsPlayerAdmin(playerid))
{
SendClientMessage(playerid,0x000000FF,"Welcome Admin in Vehicle");
}
else
{
SendClientMessage(playerid,0x000000FF,"You are not admin!");
RemovePlayerFromVehicle(playerid);
}
}
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
if(admincar)
{
if(IsPlayerAdmin(playerid))
{
SendClientMessage(playerid,0x000000FF,"Welcome Admin in Vehicle");
}
if(!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid,0x000000FF,"You are not Admin!");
RemovePlayerFromVehicle(playerid);
}
}
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new Float: fX, Float: fY, Float: fZ;
GetPlayerPos(playerid, fX, fY, fZ);
if(admincar)
{
if(IsPlayerAdmin(playerid))
{
SendClientMessage(playerid,0x000000FF,"Welcome Admin in Vehicle");
}
else
{
SendClientMessage(playerid,0x000000FF,"You are not admin!");
SetPlayerPos(playerid, fX, fY, fZ);
}
}
return 1;
}
For things like this, I think you need to use the OnPlayerUpdate callback to actually remove the player from the vehicle. Not sure if this code works as it is untested. Test it and let me know!
pawn Код:
|
Note: This function will not work when used in OnPlayerEnterVehicle because the player isn't in the vehicle yet at the time the callback is called. Suggested using OnPlayerStateChange instead. |
if(GetPlayerVehicleID(playerid) == admincar)
{
if(IsPlayerAdmin(playerid)) SendClientMessage(playerid,0x000000FF,"Welcome Admin in Vehicle");
else
{
SendClientMessage(playerid,0x000000FF,"You are not admin!");
RemovePlayerFromVehicle(playerid);
}
}
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
new admincar;
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
#endif
public OnGameModeInit()
{
admincar = AddStaticVehicle(560,1520.1329,-1622.6709,13.2541,359.9984,17,1); // Sultan 1 >>>>>>>>>>>>>>>>>
admincar = AddStaticVehicle(560,1520.7255,-1609.5054,13.2505,358.1849,17,1); // Sultan 2 >>>>>>>>>>>>>>>>>
AddStaticVehicle(555,1515.0394,-1657.7910,13.2236,286.5503,58,1); // Kola 1 >>>>>>>>>>>>>>>
AddStaticVehicle(415,1517.4779,-1669.4038,13.5506,323.7956,25,1); // Ferari 1 >>>>>>>>>>>>>>>>>>
AddStaticVehicle(500,1561.2533,-1632.5758,13.5736,75.1998,40,84); // Kola 2 >>>>>>>>>>>>
AddStaticVehicle(444,1514.9342,-1626.5626,14.3551,311.3241,32,53); // Monster Track 1 >>>>>>>>>>>>>>>>>
AddStaticVehicle(589,1535.6235,-1677.8708,13.0409,0.6939,31,31); // Kola 3 >>>>>>>>>>>>>>>>>>
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerConnect(playerid)
{
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new Float: fX, Float: fY, Float: fZ;
GetPlayerPos(playerid, fX, fY, fZ);
if(admincar)
{
if(IsPlayerAdmin(playerid))
{
SendClientMessage(playerid,0x000000FF,"Welcome Admin in Vehicle");
}
else
{
SendClientMessage(playerid,0x000000FF,"You are not admin!");
SetPlayerPos(playerid, fX, fY, fZ);
}
}
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
No, it won't work and it's really bad code. I'd use it in OnPlayerStateChange then if the new state is driver and the older was on foot, check if the vehicle is the correct and remove.
And check that it's the car! pawn Код:
|
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
new admincar;
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
#endif
public OnGameModeInit()
{
admincar = AddStaticVehicle(560,1520.1329,-1622.6709,13.2541,359.9984,17,1); // for this car work >>>>>>>>>>>>>>>>>
admincar = AddStaticVehicle(560,1520.7255,-1609.5054,13.2505,358.1849,17,1); // but for this not working >>>>>>>>>>>>>>>>>
AddStaticVehicle(555,1515.0394,-1657.7910,13.2236,286.5503,58,1); // Kola 1 >>>>>>>>>>>>>>>
AddStaticVehicle(415,1517.4779,-1669.4038,13.5506,323.7956,25,1); // Ferari 1 >>>>>>>>>>>>>>>>>>
AddStaticVehicle(500,1561.2533,-1632.5758,13.5736,75.1998,40,84); // Kola 2 >>>>>>>>>>>>
AddStaticVehicle(444,1514.9342,-1626.5626,14.3551,311.3241,32,53); // Monster Track 1 >>>>>>>>>>>>>>>>>
AddStaticVehicle(589,1535.6235,-1677.8708,13.0409,0.6939,31,31); // Kola 3 >>>>>>>>>>>>>>>>>>
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerConnect(playerid)
{
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(GetPlayerVehicleID(playerid) == admincar)
{
if(IsPlayerAdmin(playerid)) SendClientMessage(playerid,0x000000FF,"Welcome Admin in Vehicle");
else
{
SendClientMessage(playerid,0x000000FF,"You are not admin!");
RemovePlayerFromVehicle(playerid);
}
}
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
This only works for the first vehicle, but the second vehicle does not work
|
admincar = AddStaticVehicle(560,1520.1329,-1622.6709,13.2541,359.9984,17,1); // Sultan 1 >>>>>>>>>>>>>>>>>
admincar = AddStaticVehicle(560,1520.7255,-1609.5054,13.2505,358.1849,17,1); // Sultan 2 >>>>>>>>>>>>>>>>>
admincar1 = AddStaticVehicle(560,1520.1329,-1622.6709,13.2541,359.9984,17,1); // Sultan 1 >>>>>>>>>>>>>>>>>
admincar2 = AddStaticVehicle(560,1520.7255,-1609.5054,13.2505,358.1849,17,1); // Sultan 2 >>>>>>>>>>>>>>>>>
if(GetPlayerVehicleID(playerid) == admincar1 || GetPlayerVehicleID(playerid) == admincar2)
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(vehicleid == admincar && !IsPlayerAdmin(playerid))
{
GameTextForPlayer(playerid, "FOR ADMINS ONLY!", 3000, 3);
ClearAnimations(playerid);
}
return 1;
}
pawn Код:
pawn Код:
pawn Код:
|
new Admincar;
admincar = AddStaticVehicle(560,1520.1329,-1622.6709,13.2541,359.9984,17,1); // Sultan 1 >>>>>>>>>>>>>>>>>
admincar = AddStaticVehicle(560,1520.7255,-1609.5054,13.2505,358.1849,17,1); // Sultan 2 >>>>>>>>>>>>>>>>>