Moderators IIYAMA Posted February 8, 2012 Moderators Share 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? Link to comment
drk Posted February 8, 2012 Share 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) Link to comment
Moderators IIYAMA Posted February 8, 2012 Author Moderators Share 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! Link to comment
Castillo Posted February 8, 2012 Share 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 Link to comment
drk Posted February 8, 2012 Share Posted February 8, 2012 \õ/ My bad, i don't remember this function. Link to comment
Moderators IIYAMA Posted February 9, 2012 Author Moderators Share Posted February 9, 2012 yea!!!! thx man only stats set does not work wtf.. any idea why? Link to comment
Castillo Posted February 9, 2012 Share 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 Link to comment
Moderators IIYAMA Posted February 9, 2012 Author Moderators Share Posted February 9, 2012 I will try it is just very strange of that stats. You are the best scripter on the forum. Link to comment
Moderators IIYAMA Posted February 9, 2012 Author Moderators Share Posted February 9, 2012 Ah the script is good. That weapon stats does not co-operate with it -_-" Fuck mta bugs. Link to comment
Castillo Posted February 9, 2012 Share Posted February 9, 2012 Weapon stats doesn't has any bug, I've used them in one of my script's and works fine. Link to comment
Kenix Posted February 9, 2012 Share 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 ) Link to comment
Moderators IIYAMA Posted February 9, 2012 Author Moderators Share 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. 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