Jump to content

need help with extra function


jkub

Recommended Posts

here is a scipt i made a while back that puts a message to the chatbox if anybody pulls out any illegal weapon and also disable fire for them. but i wanted to add another fucntion if the gun is a minigun i want it to kick the player. i have already tried that but it does not kick the player, in the debug it says access denied @ 'kickPlayer'

how would i work around that?

function minigun ( previousWeaponID, currentWeaponID ) --when a player switches his weapon 
  
if currentWeaponID == 38 or currentWeaponID == 35 or currentWeaponID == 36 or currentWeaponID == 37 then --if the weapon ID is minigun 
     toggleControl ( source, "fire", false ) --disable the fire button 
     toggleControl ( source, "action", false ) --disable the action button ( can also fire ) 
     local name = getClientName ( source ) --get the noobs name 
     local weapon = getWeaponNameFromID ( currentWeaponID ) 
     outputChatBox ( name.. " has pulled out a " ..weapon, getRootElement(), 255, 100, 0 ) 
else --otherwise 
     toggleControl ( source, "fire", true )  --enable it 
     toggleControl ( source, "action", true ) --enable it 
end 
end 
--add an event handler for onPlayerWeaponSwitch 
addEventHandler ( "onPlayerWeaponSwitch", getRootElement(), minigun ) 
  
function killMiniNoob ( previousWeaponID, currentWeaponID  ) -- u know the drill 
if currentWeaponID == 38 then 
        setElementHealth ( source, - 5 ) 
    setTimer ( killMiniNoob, 200, 0, source, -5 ) 
    kickPlayer ( source, source, "minigun" ) 
     
end 
end 
  
addEventHandler ( "onPlayerWeaponSwitch", getRootElement(), killMiniNoob ) 

Link to comment

erm... the script doesn't look like a client-side one and im pretty sure it isn't supposed to be one.

jkub to solve the warning you are getting you need to grant the resource admin rights. You can simply do that by opening the acl.xml and adding

<object name="resource.(name of the resource that needs admin access)" /> 

to the admin group.

And well looking at your killMiniNoob function it really doesnt make sense to set a timer to call the same function 200ms later again.

Link to comment

aw ok im gonna try this when i get home. and about the settimer on the killmininoob function i think i was gonna make that into somthin but i never got to it and I was just lazy and never took it out of the script before i posted it here lol. but I will try that though and ill get back at ya

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...