Spawn Vehicles (and ranks).

Hello.

I’m currently changing some things in Cider, and I wonder if this will work?
[lua]
– Called when a player attempts to spawn a vehicle.
function GM:PlayerSpawnVehicle(player, model)
if ( !cider.player.hasAccess(player, “e”) ) then return false; end;

[/lua]

Changed into :
[lua]
– Called when a player attempts to spawn a vehicle.
function GM:PlayerSpawnVehicle(player, model)
if ply:IsAdmin() then return true;
else
if ( !cider.player.hasAccess(player, “e”) ) then return false; end;
[/lua]

And also, ply:IsAdmin, is isAdmin from the admin file? Could I make a rank named Owner, put my SteamID & name in there, then instead of ply:IsAdmin() I can put ply:IsOwner()?

ply:IsAdmin will check if the player has kick/ban/slay etc rights.

Hmm, alright.
How can I do so it checks from the admin file?

if ply:IsUserGroup(“Admin”)

Do I replace ply:IsAdmin with this?

No,

IsAdmin is the same as: IsUserGroup(“admin”) or IsUserGroup(“superadmin”)
IsSuperAdmin is the same as: IsUserGroup(“superadmin”)

[lua]pMeta = FindMetaTable(“Player”);

function pMeta:IsOwner()
return self:IsUserGroup(“owner”);
end;[/lua]

Just add an “owner” group in the users.txt exactly like how “admins” and “superadmins” is in there.

This adds a function that allows you to check if a player is in that group…

So it should look like I typed above, but instead of ply:IsAdmin, ply:IsOwner?

If you want only the Owner to spawn vehicles, yes.

[lua]

– Called when a player attempts to spawn a vehicle.
function GM:PlayerSpawnVehicle(player, model)
if ply:IsOwner() return true;
else return false; end;
[/lua]

Doesn’t work, and in users.txt :



"owner" //This is a user group. Groups are useful to LUA coders.
	{
		"-ZF:RP- Zeroi"			"STEAM_0:1:31556458"  
	}


It turns into Base Gamemode.

There should be an error somewhere.

Are you sure you have defined IsOwner in the player metatable?

Where is this metatable?

Right there, remember?

As mentioned… I’m not really aware of what this player.hasAccess does.

[lua]–Not exactly sure what ( !cider.Player.hasAccess(player, “e” ) ) does but.
–If true is the player is able to spawn then this will make admins the only ones who can spawn vehicles ( and ranks above )

function GM:PlayerSpawnVehicle(player, model)

if ply:IsAdmin() then
	if ( !cider.Player.hasAccess(player, "e" ) ) then return true
else
	if(!cider.Player.hasAccess(player, "e") )  then return false
		end
	end
end

end

[/lua]

You’re not helping. Your code is full of errors and the solution has already been posted, he just doesn’t understand it yet.

Errors? Where?

You’re missing ends and your code doesn’t make sense, why would you first check if the player is an admin and then later check if the player has the right flag, so all it ever does is check the flag.

All you wrote can be put in 3 lines:
[lua]function GM:PlayerSpawnVehicle(player, model)
return cider.Player.hasAccess(player, “e”);
end;[/lua]

I just noticed how you’re also not allowing anyone with the right flag to spawn stuff.

Well, thejjokerr, were should this Meta table be? Where do I add it?

Pay more attention to his posts.

He didnt ask what to put , but where to put.
Put it at the top of the file , or any where befor you call it.