Geramy92 Posted July 28, 2009 Share Posted July 28, 2009 function createVehicleForPlayer(thePlayer, command, vehicleModel) local playerName = getPlayerName ( thePlayer ) -- Does he have access to Admin functions? if isObjectInACLGroup ( "user." .. playerName, aclGetGroup ( "Admin" ) ) then local x,y,z = getElementPosition(thePlayer) x = x + 5 local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z) if (createdVehicle == false) then outputChatBox("Failed to create vehicle.",thePlayer) end else outputChatBox("Du bist nicht berechtigt!",thePlayer) end end [01:48:31] ERROR: ...A/mods/deathmatch/resources/reallifemod/Reallife.lua:52: attempt to call global 'getPlayerName' (a nil value) what must i do to remove this error???? (the script whit getPlayerName is from wiki) Link to comment
Shikken Posted July 29, 2009 Share Posted July 29, 2009 (edited) I bet you want to create a command: function createVehicleForPlayer(playerSource, command, vehicleModel) local playerName = getPlayerName ( playerSource ) -- Does he have access to Admin functions? if isObjectInACLGroup ( "user." .. playerName, aclGetGroup ( "Admin" ) ) then local x,y,z = getElementPosition(playerSource) y = y - 5 local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z) if (createdVehicle == false) then outputChatBox("Failed to create vehicle.", playerSource) else outputChatBox( getVehicleNameFromModel(vehicleModel).. " has been created for you!", playerSource) end else outputChatBox("Du bist nicht berechtigt!", playerSource) end end addCommandHandler ( "spawnveh", createVehicleForPlayer ) Just use a command /spawnveh 451 , this will spawn Turismo near you, for example. Edited July 29, 2009 by Guest Link to comment
xbenny2506x Posted July 29, 2009 Share Posted July 29, 2009 I have a question about this script, when i am not a admin but join in the server with the admin name without login can i use the command spawnveh too? Or must i do a login check after i ckeck the playername? Link to comment
Shikken Posted July 29, 2009 Share Posted July 29, 2009 I have a question about this script, when i am not a admin but join in the server with the admin name without login can i use the command spawnveh too?Or must i do a login check after i ckeck the playername? It work's for the non-admin player's with admin names, so yes you doesn't have to be admin. You can use HasObjectPermissionTo instead of using isObjectInACLGroup Link to comment
Geramy92 Posted July 29, 2009 Author Share Posted July 29, 2009 yes it should be a command the preoblem is another there is an error with the line getplayername see my first post this is only example everytime when i usw getplayername then there is an error Link to comment
Lordy Posted July 29, 2009 Share Posted July 29, 2009 getPlayerName is a 1.0 function, in dp2.3 you have to use getClientName. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now