Jump to content

Help About Toys-System


Recommended Posts

I just edit this script from command to event handler , But how to add this to item system , so when i use helmet (item id 90) then this event running ... Thx B4

addEvent( "helmet", true ) 
  
local cases = {} 
  
for i,v in ipairs(getElementsByType("player"))do 
        setElementData(v, "helmet", 0) 
end 
     
function helmet(player) 
    if (getResourceState(getResourceFromName("bone_attach")) == "running") then 
        if (getElementData(source, "helmet") ~=1) then 
            setElementData(source, "helmet", 1) 
            case = createObject(2054,0,0,0) 
            exports.bone_attach:attachElementToBone(case,source,1,0,0.04,0.06,0,0,180) 
            cases[source] = case 
            outputChatBox("Helmet:- True.", source, 0, 255, 0) 
        else 
            setElementData(source, "helmet", 0) 
            exports.bone_attach:detachElementFromBone(cases[source]) 
            destroyElement(cases[source]) 
            outputChatBox("Helmet:- False.", source, 255, 50, 0) 
        end 
         
    else 
        outputChatBox("ERROR #2 Resource not found.", source, 255, 50, 0) 
    end 
end 
  
addEventHandler( "helmet", player, helmet ) 

Link to comment

I just edit this script

Server.lua

  
addEvent( "helmet", true ) 
  
local cases = {} 
  
for i,v in ipairs(getElementsByType("player"))do 
        setElementData(v, "helmet", 0) 
end 
    
function helmet(player) 
    if (getResourceState(getResourceFromName("bone_attach")) == "running") then 
        if (getElementData(source, "helmet") ~=1) then 
            setElementData(source, "helmet", 1) 
            case = createObject(1210,0,0,0) 
            exports.bone_attach:attachElementToBone(case,player,12,0,0.05,0.27,0,180,0) 
            cases[source] = case 
            outputChatBox("Helmet:- True.", source, 0, 255, 0) 
        else 
            setElementData(source, "helmet", 0) 
            exports.bone_attach:detachElementFromBone(cases[source]) 
            destroyElement(cases[source]) 
            outputChatBox("Helmet:- False.", source, 255, 50, 0) 
        end 
        
    else 
        outputChatBox("ERROR #2 Resource not found.", source, 255, 50, 0) 
    end 
end 
  
addEventHandler( "helmet", root, helmet ) 
  

Item server

  
elseif (itemID==90) then --Helmet 
            triggerServerEvent("helmet", source) 
            takeItemFromSlot(source, itemSlot) 
  

I just try this, but i just get an output like this:

Helmet:- True. 

why only outputs are working, why the helmet does not appear...

I just change object to 1210, it's original files, 1210 is case, but it does not appear too

Your help is greatly appreciated :(

Link to comment

you're using player instead of source

  
addEvent( "helmet", true ) 
  
local cases = {} 
  
for i,v in ipairs(getElementsByType("player"))do 
        setElementData(v, "helmet", 0) 
end 
    
function helmet( source ) 
    if (getResourceState(getResourceFromName("bone_attach")) == "running") then 
        if (getElementData(source, "helmet") ~=1) then 
            setElementData(source, "helmet", 1) 
            case = createObject(1210,0,0,0) 
            exports.bone_attach:attachElementToBone(case,player,12,0,0.05,0.27,0,180,0) 
            cases[source] = case 
            outputChatBox("Helmet:- True.", source, 0, 255, 0) 
        else 
            setElementData(source, "helmet", 0) 
            exports.bone_attach:detachElementFromBone(cases[source]) 
            destroyElement(cases[source]) 
            outputChatBox("Helmet:- False.", source, 255, 50, 0) 
        end 
        
    else 
        outputChatBox("ERROR #2 Resource not found.", source, 255, 50, 0) 
    end 
end 
  
addEventHandler( "helmet", root, helmet ) 

Link to comment
  
  
addEvent( "helmet", true ) 
  
local cases = {} 
  
for i,v in ipairs(getElementsByType("player"))do 
        setElementData(v, "helmet", 0) 
end 
    
function helmet(player) 
    if (getResourceState(getResourceFromName("bone_attach")) == "running") then 
        if (getElementData(player, "helmet") ~=1) then 
            setElementData(player, "helmet", 1) 
            case = createObject(1210,0,0,0) 
            exports.bone_attach:attachElementToBone(case,player,12,0,0.05,0.27,0,180,0) 
            cases[player] = case 
            outputChatBox("Helmet:- True.", player, 0, 255, 0) 
        else 
            setElementData(player, "helmet", 0) 
            exports.bone_attach:detachElementFromBone(cases[player]) 
            destroyElement(cases[player]) 
            outputChatBox("Helmet:- False.", player, 255, 50, 0) 
        end 
        
    else 
        outputChatBox("ERROR #2 Resource not found.", player, 255, 50, 0) 
    end 
end 
  
addEventHandler( "helmet", root, helmet ) 
  
  

  
  
elseif (itemID==90) then --Helmet 
            triggerServerEvent("helmet", root, source) 
            takeItemFromSlot(source, itemSlot) 
  
  

Link to comment
  
addEvent( "helmet", true ) 
  
local cases = {} 
  
for i,v in ipairs(getElementsByType("player"))do 
        setElementData(v, "helmet", 0) 
end 
    
function helmet( source ) 
    if (getResourceState(getResourceFromName("bone_attach")) == "running") then 
        if (getElementData(source, "helmet") ~=1) then 
            setElementData(source, "helmet", 1) 
            case = createObject(1210,0,0,0) 
            exports.bone_attach:attachElementToBone(case,source,12,0,0.05,0.27,0,180,0) 
            cases[source] = case 
            outputChatBox("Helmet:- True.", source, 0, 255, 0) 
        else 
            setElementData(source, "helmet", 0) 
            exports.bone_attach:detachElementFromBone(cases[source]) 
            destroyElement(cases[source]) 
            outputChatBox("Helmet:- False.", source, 255, 50, 0) 
        end 
        
    else 
        outputChatBox("ERROR #2 Resource not found.", source, 255, 50, 0) 
    end 
end 
  
addEventHandler( "helmet", root, helmet ) 

  
  
elseif (itemID==90) then  
            triggerServerEvent("helmet", root, source) 
            takeItemFromSlot(source, itemSlot) 
  
  

Link to comment

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