Scripting Posted April 12, 2012 Share Posted April 12, 2012 I want ask if I can do that: set a name to weapon server side: super = giveWeapon(source,31,1000) function detect(player,weapon,super) if ( weapon == "m4" ) then killPed(player) outputChatBox("Don t use Super Weapon",player,255,255,0,true) end end addEventHandler(onPlayerFire,getRootElement(),detect) Link to comment
drk Posted April 12, 2012 Share Posted April 12, 2012 (edited) First, yes you can make this. Just create a table with id and name you want and use like "table[id].name". Second, your code is wrong. Third, tabulate your code and use LUA tags. Edit: I've not seen all, I thought that it's other thing. By your way, you can't. You must use ID because parameter "weapon" is a real number, not a string Edited April 12, 2012 by Guest Link to comment
X-SHADOW Posted April 12, 2012 Share Posted April 12, 2012 local root = getRootElement() function detect() giveWeapon ( source, 31, 1000 ) if ( weapon == 31 ) then killPed(source) outputChatBox("Don t use Super Weapon",source,255,255,0,true) end end addEventHandler("onPlayerWeaponSwitch", root, detect) Link to comment
drk Posted April 12, 2012 Share Posted April 12, 2012 local root = getRootElement() function detect() giveWeapon ( source, 31, 1000 ) if ( weapon == 31 ) then killPed(source) outputChatBox("Don t use Super Weapon",source,255,255,0,true) end end addEventHandler("onPlayerWeaponSwitch", root, detect) You know what are you doing? Everytime you change weapon, you will get killed because when player get weapon, player weapon will be the weapon you got now. Also "weapon" is nil. So: addEventHandler ( 'onPlayerWeaponSwitch', root, function ( _, nWeapon ) if ( nWeapon == 31 ) then killPed ( source ); outputChatBox ( 'You cannot use this weapon!', source, 255, 255, 255, false ); end end ) 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