alex11 Posted August 31, 2008 Share Posted August 31, 2008 This Script got from MTA-Wiki,and I am try to Add Only Admin can use minigun. function weaponSwitchDisableMinigun ( previousWeaponID, currentWeaponID, thePlayer ) --when a player switches his weapon if currentWeaponID == 38 then --if the weapon ID is minigun toggleControl ( source, "fire", false ) --disable the fire button else --otherwise toggleControl ( source, "fire", true ) --enable it end if getClientName(thePlayer) == "MyNickname" then toggleControl ( source, "fire", true ) --enable it end end --add an event handler for onPlayerWeaponSwitch addEventHandler ( "onPlayerWeaponSwitch", getRootElement(), weaponSwitchDisableMinigun ) I try write this script get PlayerName is Admin Name can use minigun,but it was not work. I want to write it,Only AdminGroup Can use minigun. Please,Help me~ Link to comment
[UVA]Bart Posted August 31, 2008 Share Posted August 31, 2008 i would create ma own xml file with my own admin list, then loop through the admin node and see if the players serial is in the xml if it is then do the minigun thing. "0000-0000-0000-0000"/> "0000-0000-0000-0000"/> but the serial thing is broken and i allways do it the wrong way accoring to most people Link to comment
alex11 Posted August 31, 2008 Author Share Posted August 31, 2008 My serial is 0000-0000-0000-0000 Under the XML,where did I Add in which file? <admins> <admin Serial="0000-0000-0000-0000"/> <admin Serial="0000-0000-0000-0000"/> </admins> Link to comment
Ace_Gambit Posted August 31, 2008 Share Posted August 31, 2008 Performing authentication based on nicknames is not a good idea. You should really learn how to use the Client, Account and ACL scripting functions imo. You could try something like this (provided that you have some kind of function that allows players to login to an account). function isAdminAccount(account) local nick = "" local group = aclGetGroup("Admin") if (account and group) then nick = string.lower(getAccountName(account) or "") for _, object in ipairs(aclGroupListObjects(group) or {}) do if (gettok(object, 1, string.byte('.')) == "user") then if (nick == string.lower(gettok(object, 2, string.byte('.')))) then return true end end end end return false end Link to comment
[UVA]Bart Posted August 31, 2008 Share Posted August 31, 2008 Quote Performing authentication based on nicknames is not a good idea. You should really learn how to use the Client, Account and ACL scripting functions imo.You could try something like this (provided that you have some kind of function that allows players to login to an account). i wasnt using nicks i was using serials, but its broken in this version which i stated. Link to comment
Ace_Gambit Posted August 31, 2008 Share Posted August 31, 2008 [UVA]Bart said: i wasnt using nicks i was using serials, but its broken in this version which i stated. I know. I wasn't referring to you in my post. It was just that I typed the message 1 hour ago but forget to actually post it lol. Link to comment
alex11 Posted August 31, 2008 Author Share Posted August 31, 2008 My server have Install logingui resources.Every One have they own Account. function weaponSwitchDisableMinigun ( previousWeaponID, currentWeaponID, thePlayer ) --when a player switches his weapon if currentWeaponID == 38 then --if the weapon ID is minigun toggleControl ( source, "fire", false ) --disable the fire button else --otherwise toggleControl ( source, "fire", true ) --enable it end local taccount = getClientAccount ( thePlayer ) if isAdminAccount(taccount) then toggleControl ( source, "fire", true ) --enable it end end function isAdminAccount(account) local nick = "" local group = aclGetGroup("Admin") if (account and group) then nick = string.lower(getAccountName(account) or "") for _, object in ipairs(aclGroupListObjects(group) or {}) do if (gettok(object, 1, string.byte('.')) == "user") then if (nick == string.lower(gettok(object, 2, string.byte('.')))) then return true end end end end return false end --add an event handler for onPlayerWeaponSwitch addEventHandler ( "onPlayerWeaponSwitch", getRootElement(), weaponSwitchDisableMinigun ) It's can't work. Link to comment
[UVA]Bart Posted August 31, 2008 Share Posted August 31, 2008 try this a think it will work a just edited it a bit unfortunatly i cannot test cause my gta wont install function weaponSwitchDisableMinigun ( previousWeaponID, currentWeaponID, thePlayer ) --when a player switches his weapon if (currentWeaponID == 38) then --if the weapon ID is minigun elseif ( isAdminAccount( getClientAccount ( thePlayer ) ) == true ) then toggleControl ( source, "fire", true ) --enable it elseif ( isAdminAccount( getClientAccount ( thePlayer ) ) == false ) then toggleControl ( source, "fire", false ) --disable the fire button else --otherwise if ( currentWeaponID ~= 38 ) then toggleControl ( source, "fire", true ) --enable it end end end Link to comment
alex11 Posted August 31, 2008 Author Share Posted August 31, 2008 [UVA]Bart said: try this a think it will work a just edited it a bit unfortunatly i cannot test cause my gta wont install function weaponSwitchDisableMinigun ( previousWeaponID, currentWeaponID, thePlayer ) --when a player switches his weapon if (currentWeaponID == 38) then --if the weapon ID is minigun elseif ( isAdminAccount( getClientAccount ( thePlayer ) ) == true ) then toggleControl ( source, "fire", true ) --enable it elseif ( isAdminAccount( getClientAccount ( thePlayer ) ) == false ) then toggleControl ( source, "fire", false ) --disable the fire button else --otherwise if ( currentWeaponID ~= 38 ) then toggleControl ( source, "fire", true ) --enable it end end end myrules.lua function weaponSwitchDisableMinigun ( previousWeaponID, currentWeaponID, thePlayer ) --when a player switches his weapon if currentWeaponID == 38 then --if the weapon ID is minigun toggleControl ( source, "fire", false ) --disable the fire button else --otherwise toggleControl ( source, "fire", true ) --enable it end if (isAdminAccount(getClientAccount ( thePlayer )) == true) then toggleControl ( source, "fire", true ) --enable it end end function isAdminAccount(account) local nick = "" local group = aclGetGroup("Admin") if (account and group) then nick = string.lower(getAccountName(account) or "") for _, object in ipairs(aclGroupListObjects(group) or {}) do if (gettok(object, 1, string.byte('.')) == "user") then if (nick == string.lower(gettok(object, 2, string.byte('.')))) then return true end end end end return false end --add an event handler for onPlayerWeaponSwitch addEventHandler ( "onPlayerWeaponSwitch", getRootElement(), weaponSwitchDisableMinigun ) myrules.lua and [uVA]Bart Give me his lua will Show same error messages. ERROR MESSAGE SHOW ON CONSOLE [23:50:48] WARNING: myrules.server.lua: Bad argument @ 'getClientAccount' - Line: 9 what's happen? Link to comment
Ace_Gambit Posted August 31, 2008 Share Posted August 31, 2008 function weaponSwitchDisableMinigun ( previousWeaponID, currentWeaponID, thePlayer ) --when a player switches his weapon if currentWeaponID == 38 then --if the weapon ID is minigun toggleControl ( source, "fire", false ) --disable the fire button else --otherwise toggleControl ( source, "fire", true ) --enable it end if (isAdminAccount(getClientAccount ( thePlayer )) == true) then toggleControl ( source, "fire", true ) --enable it end end Should be: function weaponSwitchDisableMinigun ( previousWeaponID, currentWeaponID) --when a player switches his weapon if currentWeaponID == 38 then --if the weapon ID is minigun toggleControl ( source, "fire", false ) --disable the fire button else --otherwise toggleControl ( source, "fire", true ) --enable it end if (isAdminAccount(getClientAccount ( source )) == true) then toggleControl ( source, "fire", true ) --enable it end end Link to comment
alex11 Posted September 1, 2008 Author Share Posted September 1, 2008 local spawnX = 2496 local spawnY = -1684 local spawnZ = 14 function weaponSwitchDisableMyWeapon ( previousWeaponID, currentWeaponID) --when a player switches his weapon if currentWeaponID == 38 or currentWeaponID == 36 then --if the weapon ID is minigun toggleControl ( source, "fire", false ) --disable the fire button toggleControl ( source, "action", false ) --disable the fire button else --otherwise toggleControl ( source, "fire", true ) --enable it toggleControl ( source, "action", true ) --disable the fire button end if (isAdminAccount(getClientAccount ( source )) == true) then toggleControl ( source, "fire", true ) --enable it toggleControl ( source, "action", true ) --disable the fire button end end --add an event handler for onPlayerWeaponSwitch addEventHandler ( "onPlayerWeaponSwitch", getRootElement(), weaponSwitchDisableMyWeapon ) function isAdminAccount(account) local nick = "" local group = aclGetGroup("Admin") if (account and group) then nick = string.lower(getAccountName(account) or "") for _, object in ipairs(aclGroupListObjects(group) or {}) do if (gettok(object, 1, string.byte('.')) == "user") then if (nick == string.lower(gettok(object, 2, string.byte('.')))) then return true end end end end return false end function giveWeaponsOnMyEvent ( ) giveWeapon ( source, 5, 1 ) giveWeapon ( source, 22, 35 ) giveWeapon ( source, 25, 32 ) giveWeapon ( source, 29, 200 ) giveWeapon ( source, 31, 100 ) --giveWeapon ( source, 17, 25 ) --giveWeapon ( source, 42, 500 ) end addEventHandler ( "onPlayerJoin", getRootElement(), giveWeaponsOnMyEvent ) -- attach the event handler addEventHandler ( "onPlayerWasted", getRootElement(), giveWeaponsOnMyEvent ) -- attach the event handler addEventHandler ( "onPlayerSpawn", getRootElement(), giveWeaponsOnMyEvent ) function Wait_Timer ( ) end function player_Wasted_Spawn () setTimer ( Wait_Timer, 3000, 1, "Hello, World!" ) spawnPlayer(source,spawnX,spawnY,spawnZ) end addEventHandler ( "onPlayerWasted", getRootElement(), player_Wasted_Spawn ) This is Finish...but Player be kill,that's no delay goto CJ old safe hose. And lock Action(TAB),if player use minigun,Press Mouse Right button,and Press TAB(Action),it will fire... so lock TAB(Action) Link to comment
DiSaMe Posted September 1, 2008 Share Posted September 1, 2008 alex11 said: This is Finish...but Player be kill,that's no delay goto CJ old safe hose. Of course, because you didn't use timer on that. You used timer on an empty function. Link to comment
Beethoven Posted January 14, 2009 Share Posted January 14, 2009 would this work? (if i put it in acl, group default) if not, can someone how i diable spawning of minigun? Link to comment
[DKR]silverfang Posted January 14, 2009 Share Posted January 14, 2009 alex11 said: local spawnX = 2496 local spawnY = -1684 local spawnZ = 14 function Wait_Timer ( thePlayer ) spawnPlayer(thePlayer ,spawnX,spawnY,spawnZ) end function player_Wasted_Spawn () setTimer ( Wait_Timer, 3000, 1, source ) end addEventHandler ( "onPlayerWasted", getRootElement(), player_Wasted_Spawn ) That's what I would do, or alternativly do setTimer ( spawnPlayer, 3000, 1, source, spawnX, spawnY, spawnZ ) in the place of the other timer Link to comment
arc_ Posted January 14, 2009 Share Posted January 14, 2009 Beethoven said: would this work? (if i put it in acl, group default) No it wouldn't. First of all, "function.name" is used for scripting functions like killPlayer(), not console commands - for those you use "command.name". Also, I'm pretty sure that a "command.give 38" right will not work. Beethoven said: if not, can someone how i diable spawning of minigun? If you are using the freeroam resource, you can specify disabled weapons in meta.xml. For other resources there might be a setting like this, but it's more likely you will have to edit the code of the command handler. Link to comment
Beethoven Posted January 14, 2009 Share Posted January 14, 2009 arc_ said: If you are using the freeroam resource, you can specify disabled weapons in meta.xml. For other resources there might be a setting like this, but it's more likely you will have to edit the code of the command handler. I removed that one when i made it, can someone post it, the anti-minigun? 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