Moderators IIYAMA Posted February 8, 2012 Moderators Posted February 8, 2012 --SERVER SIDE!!! alreadyS = 0 function bind () bindkey ( source ,"x", "down", function(player, key, state) if currentWeaponID == 34 then if alreadyS == 0 then setPedStat ( player, 79, 300 ) alreadyS = 1 outputChatBox("Works", player, 255, 69, 0) else setPedStat ( player, 79, 999 ) alreadyS = 0 outputChatBox("works!!.", player, 255, 69, 0) end end end ) end addEventHandler ( "onPlayerJoin", getRootElement(), bind ) I am trying to change the stat of a sniper with the button X. (server side) What did I do wrong? Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
drk Posted February 8, 2012 Posted February 8, 2012 currentWeaponID is nil.. I think in MTASA you can't see what weapon player are using. What I can do.. alreadyS = 0 bindKey(source,'x','down', function() if alreadyS == 0 then setPedStat(source,79,300) alreadyS = 1 outputChatBox('Works fine!', source, 255, 69, 0) else setPedStat(source,79,999) alreadyS = 0 outputChatBox('It works oO',source,255,69,0) end end) EPT Team Server Development: 0% Learning C++ | C++ is amazing
Moderators IIYAMA Posted February 8, 2012 Author Moderators Posted February 8, 2012 warning: bindKey(source,'x','down', bad argument: bindkey Pls, if somebody knows how to fix this or do it on another way. Help me! Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Castillo Posted February 8, 2012 Posted February 8, 2012 currentWeaponID is nil.. I think in MTASA you can't see what weapon player are using.What I can do.. alreadyS = 0 bindKey(source,'x','down', function() if alreadyS == 0 then setPedStat(source,79,300) alreadyS = 1 outputChatBox('Works fine!', source, 255, 69, 0) else setPedStat(source,79,999) alreadyS = 0 outputChatBox('It works oO',source,255,69,0) end end) it is possible, just use "getPedWeapon". alreadyS = 0 addEventHandler("onPlayerJoin",root, function () bindKey(source,"x","down",setStat) end) addEventHandler("onResourceStart",resourceRoot, function () for index, player in ipairs(getElementsByType("player")) do bindKey(player,"x","down",setStat) end end) function setStat(player) local currentWeaponID = getPedWeapon(player) if (currentWeaponID == 34) then if (alreadyS == 0) then setPedStat ( player, 79, 300 ) alreadyS = 1 outputChatBox("Works", player, 255, 69, 0) else setPedStat ( player, 79, 999 ) alreadyS = 0 outputChatBox("works!!.", player, 255, 69, 0) end end end San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
drk Posted February 8, 2012 Posted February 8, 2012 \õ/ My bad, i don't remember this function. EPT Team Server Development: 0% Learning C++ | C++ is amazing
Moderators IIYAMA Posted February 9, 2012 Author Moderators Posted February 9, 2012 yea!!!! thx man only stats set does not work wtf.. any idea why? Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Castillo Posted February 9, 2012 Posted February 9, 2012 Well, it has to work, maybe you put it vice-versa? like this: alreadyS = 0 addEventHandler("onPlayerJoin",root, function () bindKey(source,"x","down",setStat) end) addEventHandler("onResourceStart",resourceRoot, function () for index, player in ipairs(getElementsByType("player")) do bindKey(player,"x","down",setStat) end end) function setStat(player) local currentWeaponID = getPedWeapon(player) if (currentWeaponID == 34) then if (alreadyS == 0) then setPedStat ( player, 79, 999 ) alreadyS = 1 outputChatBox("Works", player, 255, 69, 0) else setPedStat ( player, 79, 300 ) alreadyS = 0 outputChatBox("works!!.", player, 255, 69, 0) end end end San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Moderators IIYAMA Posted February 9, 2012 Author Moderators Posted February 9, 2012 I will try it is just very strange of that stats. You are the best scripter on the forum. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Moderators IIYAMA Posted February 9, 2012 Author Moderators Posted February 9, 2012 Ah the script is good. That weapon stats does not co-operate with it -_-" Fuck mta bugs. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Castillo Posted February 9, 2012 Posted February 9, 2012 Weapon stats doesn't has any bug, I've used them in one of my script's and works fine. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Kenix Posted February 9, 2012 Posted February 9, 2012 local state = { } function setStat( player ) local currentWeaponID = getPedWeapon( player ) if currentWeaponID == 34 then state[ player ] = not state[ player ] if state[ player ] then setPedStat ( player, 79, 999 ) outputChatBox( "Works", player, 255, 69, 0 ) else setPedStat ( player, 79, 300 ) outputChatBox( "works!!.", player, 255, 69, 0 ) end else outputChatBox( 'Weapon should be 34 ID' ) end end addEventHandler( "onPlayerJoin",root, function ( ) bindKey( source,"x","down",setStat ) end ) addEventHandler( 'onPlayerQuit',root, function( ) state[ source ] = nil end ) addEventHandler( "onResourceStart",resourceRoot, function ( ) for _, v in pairs( getElementsByType 'player' ) do bindKey( v,"x","down",setStat ) end end ) http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Moderators IIYAMA Posted February 9, 2012 Author Moderators Posted February 9, 2012 Weapon stats doesn't has any bug, I've used them in one of my script's and works fine. Weapon stats in combination of weaponproperties does not. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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