LiOneLMeSsIShoT Posted July 13, 2013 Posted July 13, 2013 I want to make this script shows the player stat in this panel...idk why it's not work can someone help me please... server side: function ZombieKill ( killer, weapon, bodypart) if (killer and killer ~= source) then if ( bodypart = 9 ) then setPedStat(killer, 69, +5) end end end addEventHandler("onZombieWasted",getRootElement(),ZombieKill) Client Side: --[[------------------------------------------------- Notes: > This code is using a relative image filepath. This will only work as long as the location it is from always exists, and the resource it is part of is running. To ensure it does not break, it is highly encouraged to move images into your local resource and reference them there. --]]------------------------------------------------- GUIEditor = { window = {}, staticimage = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(295, 115, 457, 548, "Weapon Skills Panel", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.staticimage[1] = guiCreateStaticImage(25, 46, 63, 58, ":shop1/images/22.png", false, GUIEditor.window[1]) GUIEditor.label[1] = guiCreateLabel(90, 84, 22, 15, "0%", false, GUIEditor.window[1]) end ) function Nothing() guiSetText(GUIEditor.label[1],""..getPedStat(source, 69)) end addEventHandler("onClientRender", getRootElement(), Nothing) bindKey("F7","Down",function() guiSetVisible(GUIEditor.window[1],not guiGetVisible(GUIEditor.window[1])) showCursor(guiGetVisible(GUIEditor.window[1])) end) and thanks for helping
iPrestege Posted July 13, 2013 Posted July 13, 2013 Try this : function ZombieKill ( killer, weapon, bodypart) if ( killer and killer ~= source and getElementType ( killer ) == 'player' ) then if ( bodypart = 9 ) then local old = getPedStat ( killer,69 ) local new = old +5 setPedStat(killer, 69,new ) end end end addEventHandler("onZombieWasted",getRootElement(),ZombieKill) addEvent("onZombieWasted",true) GUIEditor = { window = {}, staticimage = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(295, 115, 457, 548, "Weapon Skills Panel", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.staticimage[1] = guiCreateStaticImage(25, 46, 63, 58, ":shop1/images/22.png", false, GUIEditor.window[1]) GUIEditor.label[1] = guiCreateLabel(90, 84, 22, 15, "0%", false, GUIEditor.window[1]) end ) function Nothing() local stat = getPedStat( localPlayer, 69 ) guiSetText( GUIEditor.label[1],""..stat ) end addEventHandler("onClientRender", getRootElement(), Nothing) bindKey("F7","down", function() guiSetVisible(GUIEditor.window[1],not guiGetVisible(GUIEditor.window[1])) showCursor(guiGetVisible(GUIEditor.window[1])) end)
LiOneLMeSsIShoT Posted July 13, 2013 Author Posted July 13, 2013 Try this : function ZombieKill ( killer, weapon, bodypart) if ( killer and killer ~= source and getElementType ( killer ) == 'player' ) then if ( bodypart = 9 ) then local old = getPedStat ( killer,69 ) local new = old +5 setPedStat(killer, 69,new ) end end end addEventHandler("onZombieWasted",getRootElement(),ZombieKill) addEvent("onZombieWasted",true) GUIEditor = { window = {}, staticimage = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(295, 115, 457, 548, "Weapon Skills Panel", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.staticimage[1] = guiCreateStaticImage(25, 46, 63, 58, ":shop1/images/22.png", false, GUIEditor.window[1]) GUIEditor.label[1] = guiCreateLabel(90, 84, 22, 15, "0%", false, GUIEditor.window[1]) end ) function Nothing() local stat = getPedStat( localPlayer, 69 ) guiSetText( GUIEditor.label[1],""..stat ) end addEventHandler("onClientRender", getRootElement(), Nothing) bindKey("F7","down", function() guiSetVisible(GUIEditor.window[1],not guiGetVisible(GUIEditor.window[1])) showCursor(guiGetVisible(GUIEditor.window[1])) end) okay look before i test the script..there's another problem..when the resource start ..the panel opens over my face..i want to remove the event handler called onClientResourceStart..already removed it but the script not work anymore..then puted it again..please may you help with this?
iPrestege Posted July 13, 2013 Posted July 13, 2013 Client : GUIEditor = { window = {}, staticimage = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(295, 115, 457, 548, "Weapon Skills Panel", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetVisible ( GUIEditor.window[1],false ) GUIEditor.staticimage[1] = guiCreateStaticImage(25, 46, 63, 58, ":shop1/images/22.png", false, GUIEditor.window[1]) GUIEditor.label[1] = guiCreateLabel(90, 84, 22, 15, "0%", false, GUIEditor.window[1]) end ) function Nothing() local stat = getPedStat( localPlayer, 69 ) guiSetText( GUIEditor.label[1],""..stat ) end addEventHandler("onClientRender", getRootElement(), Nothing) bindKey("F7","down", function() guiSetVisible(GUIEditor.window[1],not guiGetVisible(GUIEditor.window[1])) showCursor(guiGetVisible(GUIEditor.window[1])) end)
LiOneLMeSsIShoT Posted July 13, 2013 Author Posted July 13, 2013 Try this : function ZombieKill ( killer, weapon, bodypart) if ( killer and killer ~= source and getElementType ( killer ) == 'player' ) then if ( bodypart = 9 ) then local old = getPedStat ( killer,69 ) local new = old +5 setPedStat(killer, 69,new ) end end end addEventHandler("onZombieWasted",getRootElement(),ZombieKill) addEvent("onZombieWasted",true) GUIEditor = { window = {}, staticimage = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(295, 115, 457, 548, "Weapon Skills Panel", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.staticimage[1] = guiCreateStaticImage(25, 46, 63, 58, ":shop1/images/22.png", false, GUIEditor.window[1]) GUIEditor.label[1] = guiCreateLabel(90, 84, 22, 15, "0%", false, GUIEditor.window[1]) end ) function Nothing() local stat = getPedStat( localPlayer, 69 ) guiSetText( GUIEditor.label[1],""..stat ) end addEventHandler("onClientRender", getRootElement(), Nothing) bindKey("F7","down", function() guiSetVisible(GUIEditor.window[1],not guiGetVisible(GUIEditor.window[1])) showCursor(guiGetVisible(GUIEditor.window[1])) end) okay look before i test the script..there's another problem..when the resource start ..the panel opens over my face..i want to remove the event handler called onClientResourceStart..already removed it but the script not work anymore..then puted it again..please may you help with this? After test..ERROR WeaponPoints.lua:3: ')' expect near '='
iPrestege Posted July 13, 2013 Posted July 13, 2013 Sorry change this : function ZombieKill ( killer, weapon, bodypart) if ( killer and killer ~= source and getElementType ( killer ) == 'player' ) then if ( bodypart = 9 ) then local old = getPedStat ( killer,69 ) local new = old +5 setPedStat(killer, 69,new ) end end end addEventHandler("onZombieWasted",getRootElement(),ZombieKill) addEvent("onZombieWasted",true) To : function ZombieKill ( killer, weapon, bodypart) if ( killer and killer ~= source and getElementType ( killer ) == 'player' ) then if ( bodypart == 9 ) then local old = getPedStat ( killer,69 ) local new = old +5 setPedStat(killer, 69,new ) end end end addEventHandler("onZombieWasted",getRootElement(),ZombieKill) addEvent("onZombieWasted",true)
codeluaeveryday Posted July 13, 2013 Posted July 13, 2013 IFahad's code won't work again, you need to addEvent before registering the event. Otherwise lua doesn't recognize it (I think) Server: function ZombieKill ( killer, weapon, bodypart) if (killer and killer ~= source) then if bodypart == 9 then setPedStat(killer, 69, getPedStat(killer, 69) + 5) end end end addEvent("onZombieWasted", true) addEventHandler("onZombieWasted",getRootElement(),ZombieKill) Client: --[[------------------------------------------------- Notes: > This code is using a relative image filepath. This will only work as long as the location it is from always exists, and the resource it is part of is running. To ensure it does not break, it is highly encouraged to move images into your local resource and reference them there. --]]------------------------------------------------- GUIEditor = { window = {}, staticimage = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(295, 115, 457, 548, "Weapon Skills Panel", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.staticimage[1] = guiCreateStaticImage(25, 46, 63, 58, ":shop1/images/22.png", false, GUIEditor.window[1]) GUIEditor.label[1] = guiCreateLabel(90, 84, 22, 15, "0%", false, GUIEditor.window[1]) end ) function Nothing() guiSetText(GUIEditor.label[1], getPedStat(localPlayer, 69)) end addEventHandler("onClientRender", getRootElement(), Nothing) bindKey("F7","Down",function() guiSetVisible(GUIEditor.window[1], not guiGetVisible(GUIEditor.window[1])) showCursor(guiGetVisible(GUIEditor.window[1])) end)
LiOneLMeSsIShoT Posted July 13, 2013 Author Posted July 13, 2013 IFahad's code won't work again, you need to addEvent before registering the event. Otherwise lua doesn't recognize it (I think)Server: function ZombieKill ( killer, weapon, bodypart) if (killer and killer ~= source) then if bodypart == 9 then setPedStat(killer, 69, getPedStat(killer, 69) + 5) end end end addEvent("onZombieWasted", true) addEventHandler("onZombieWasted",getRootElement(),ZombieKill) Client: --[[------------------------------------------------- Notes: > This code is using a relative image filepath. This will only work as long as the location it is from always exists, and the resource it is part of is running. To ensure it does not break, it is highly encouraged to move images into your local resource and reference them there. --]]------------------------------------------------- GUIEditor = { window = {}, staticimage = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(295, 115, 457, 548, "Weapon Skills Panel", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.staticimage[1] = guiCreateStaticImage(25, 46, 63, 58, ":shop1/images/22.png", false, GUIEditor.window[1]) GUIEditor.label[1] = guiCreateLabel(90, 84, 22, 15, "0%", false, GUIEditor.window[1]) end ) function Nothing() guiSetText(GUIEditor.label[1], getPedStat(localPlayer, 69)) end addEventHandler("onClientRender", getRootElement(), Nothing) bindKey("F7","Down",function() guiSetVisible(GUIEditor.window[1], not guiGetVisible(GUIEditor.window[1])) showCursor(guiGetVisible(GUIEditor.window[1])) end) Thanks a lot ...And Thanks a lot Ifahad too!!
LiOneLMeSsIShoT Posted July 13, 2013 Author Posted July 13, 2013 IFahad's code won't work again, you need to addEvent before registering the event. Otherwise lua doesn't recognize it (I think)Server: function ZombieKill ( killer, weapon, bodypart) if (killer and killer ~= source) then if bodypart == 9 then setPedStat(killer, 69, getPedStat(killer, 69) + 5) end end end addEvent("onZombieWasted", true) addEventHandler("onZombieWasted",getRootElement(),ZombieKill) Client: --[[------------------------------------------------- Notes: > This code is using a relative image filepath. This will only work as long as the location it is from always exists, and the resource it is part of is running. To ensure it does not break, it is highly encouraged to move images into your local resource and reference them there. --]]------------------------------------------------- GUIEditor = { window = {}, staticimage = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(295, 115, 457, 548, "Weapon Skills Panel", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.staticimage[1] = guiCreateStaticImage(25, 46, 63, 58, ":shop1/images/22.png", false, GUIEditor.window[1]) GUIEditor.label[1] = guiCreateLabel(90, 84, 22, 15, "0%", false, GUIEditor.window[1]) end ) function Nothing() guiSetText(GUIEditor.label[1], getPedStat(localPlayer, 69)) end addEventHandler("onClientRender", getRootElement(), Nothing) bindKey("F7","Down",function() guiSetVisible(GUIEditor.window[1], not guiGetVisible(GUIEditor.window[1])) showCursor(guiGetVisible(GUIEditor.window[1])) end) Thanks a lot ...And Thanks a lot Ifahad too!! lol...when i just shot and kill zombie with another weapon too..the points get saved!! lol ..any weapon i kill zombie with...saves in the same label !..and the problem's back again..when i just open the resource..the panel come over my face and say hello again
LiOneLMeSsIShoT Posted July 13, 2013 Author Posted July 13, 2013 IFahad's code won't work again, you need to addEvent before registering the event. Otherwise lua doesn't recognize it (I think)Server: function ZombieKill ( killer, weapon, bodypart) if (killer and killer ~= source) then if bodypart == 9 then setPedStat(killer, 69, getPedStat(killer, 69) + 5) end end end addEvent("onZombieWasted", true) addEventHandler("onZombieWasted",getRootElement(),ZombieKill) Client: --[[------------------------------------------------- Notes: > This code is using a relative image filepath. This will only work as long as the location it is from always exists, and the resource it is part of is running. To ensure it does not break, it is highly encouraged to move images into your local resource and reference them there. --]]------------------------------------------------- GUIEditor = { window = {}, staticimage = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(295, 115, 457, 548, "Weapon Skills Panel", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.staticimage[1] = guiCreateStaticImage(25, 46, 63, 58, ":shop1/images/22.png", false, GUIEditor.window[1]) GUIEditor.label[1] = guiCreateLabel(90, 84, 22, 15, "0%", false, GUIEditor.window[1]) end ) function Nothing() guiSetText(GUIEditor.label[1], getPedStat(localPlayer, 69)) end addEventHandler("onClientRender", getRootElement(), Nothing) bindKey("F7","Down",function() guiSetVisible(GUIEditor.window[1], not guiGetVisible(GUIEditor.window[1])) showCursor(guiGetVisible(GUIEditor.window[1])) end) Thanks a lot ...And Thanks a lot Ifahad too!! lol...when i just shot and kill zombie with another weapon too..the points get saved!! lol ..any weapon i kill zombie with...saves in the same label !..and the problem's back again..when i just open the resource..the panel come over my face and say hello again Please still need your help guys!!..when i use another weapon to kill a a zombie..the points get saved in the same label...i made this label only for Colt-45 Slot Weapon ID 22....Please help..and when i start the resource...i get the panel over my screen..and i made it works only with f7..help
PaiN^ Posted July 13, 2013 Posted July 13, 2013 Try this : --[[------------------------------------------------- Notes: > This code is using a relative image filepath. This will only work as long as the location it is from always exists, and the resource it is part of is running. To ensure it does not break, it is highly encouraged to move images into your local resource and reference them there. --]]------------------------------------------------- GUIEditor = { window = {}, staticimage = {}, label = {} }; addEventHandler( "onClientResourceStart", resourceRoot, function( ) GUIEditor.window[1] = guiCreateWindow( 295, 115, 457, 548, "Weapon Skills Panel", false ); guiWindowSetSizable( GUIEditor.window[1], false ); guiSetVisible( GUIEditor.window[1], false ); GUIEditor.staticimage[1] = guiCreateStaticImage( 25, 46, 63, 58, ":shop1/images/22.png", false, GUIEditor.window[1] ); GUIEditor.label[1] = guiCreateLabel( 90, 84, 22, 15, "0%", false, GUIEditor.window[1] ); end ); function Nothing() guiSetText( GUIEditor.label[1], getPedStat( localPlayer, 69 ) ); end addEventHandler( "onClientRender", root, Nothing ); bindKey( "F7", "Down", function( ) guiSetVisible( GUIEditor.window[1], not guiGetVisible( GUIEditor.window[1] ) ); showCursor( guiGetVisible( GUIEditor.window[1] ) ); end ); addEvent( "onZombieWasted", true ); addEventHandler( "onZombieWasted", root, function ZombieKill( killer, weapon, bodypart ) if killer and killer ~= source then if bodypart == 9 and weapon == 69 then setPedStat( killer, 69, getPedStat( killer, 69 ) + 5 ); end end end );
LiOneLMeSsIShoT Posted July 13, 2013 Author Posted July 13, 2013 Try this : --[[------------------------------------------------- Notes: > This code is using a relative image filepath. This will only work as long as the location it is from always exists, and the resource it is part of is running. To ensure it does not break, it is highly encouraged to move images into your local resource and reference them there. --]]------------------------------------------------- GUIEditor = { window = {}, staticimage = {}, label = {} }; addEventHandler( "onClientResourceStart", resourceRoot, function( ) GUIEditor.window[1] = guiCreateWindow( 295, 115, 457, 548, "Weapon Skills Panel", false ); guiWindowSetSizable( GUIEditor.window[1], false ); guiSetVisible( GUIEditor.window[1], false ); GUIEditor.staticimage[1] = guiCreateStaticImage( 25, 46, 63, 58, ":shop1/images/22.png", false, GUIEditor.window[1] ); GUIEditor.label[1] = guiCreateLabel( 90, 84, 22, 15, "0%", false, GUIEditor.window[1] ); end ); function Nothing() guiSetText( GUIEditor.label[1], getPedStat( localPlayer, 69 ) ); end addEventHandler( "onClientRender", root, Nothing ); bindKey( "F7", "Down", function( ) guiSetVisible( GUIEditor.window[1], not guiGetVisible( GUIEditor.window[1] ) ); showCursor( guiGetVisible( GUIEditor.window[1] ) ); end ); addEvent( "onZombieWasted", true ); addEventHandler( "onZombieWasted", root, function ZombieKill( killer, weapon, bodypart ) if killer and killer ~= source then if bodypart == 9 and weapon == 69 then setPedStat( killer, 69, getPedStat( killer, 69 ) + 5 ); end end end ); ERROR: WeaponPoints.lua:3: '(' expect near 'ZombieKill'
iPrestege Posted July 13, 2013 Posted July 13, 2013 addEvent( "onZombieWasted", true ); addEventHandler( "onZombieWasted", root, function ( killer, weapon, bodypart ) if killer and killer ~= source then if bodypart == 9 and weapon == 69 then setPedStat( killer, 69, getPedStat( killer, 69 ) + 5 ); end end end );
LiOneLMeSsIShoT Posted July 13, 2013 Author Posted July 13, 2013 addEvent( "onZombieWasted", true ); addEventHandler( "onZombieWasted", root, function ( killer, weapon, bodypart ) if killer and killer ~= source then if bodypart == 9 and weapon == 69 then setPedStat( killer, 69, getPedStat( killer, 69 ) + 5 ); end end end ); Working 100% when changed the weapon == 69 to 22 .Thanks
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