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?

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) 

  • 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!

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 

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 

  • Moderators
Posted

I will try it is just very strange of that stats.

You are the best scripter on the forum.

  • Moderators
Posted

Ah the script is good.

That weapon stats does not co-operate with it -_-"

Fuck mta bugs.

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 
) 
  

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

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