Jump to content

Help pls!


IIYAMA

Recommended Posts

  • Moderators
Posted
  
--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 

  Tutorials  4x 

 

Posted

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 xD

  • Moderators
Posted

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 

  Tutorials  4x 

 

Posted
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.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

  • Moderators
Posted

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 

  Tutorials  4x 

 

Posted

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.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

  • Moderators
Posted

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 

  Tutorials  4x 

 

  • Moderators
Posted

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 

  Tutorials  4x 

 

Posted

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.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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
Posted
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 

  Tutorials  4x 

 

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...