Wei Posted April 7, 2012 Share Posted April 7, 2012 Hi. How can I add here when player repair car he will get 1000$ CODE: function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) if (weapon == 41 and hitElement and getElementType(hitElement)=="vehicle") then if getElementHealth(hitElement) >= 1000 then return end setElementHealth(hitElement, getElementHealth(hitElement)+100) end end addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc ) Link to comment
Kenix Posted April 7, 2012 Share Posted April 7, 2012 Hi. How can I add here when player repair car he will get 1000$ CODE: function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) if (weapon == 41 and hitElement and getElementType(hitElement)=="vehicle") then if getElementHealth(hitElement) >= 1000 then return end setElementHealth(hitElement, getElementHealth(hitElement)+100) end end addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc ) givePlayerMoney Link to comment
Wei Posted April 7, 2012 Author Share Posted April 7, 2012 Hi. How can I add here when player repair car he will get 1000$ CODE: function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) if (weapon == 41 and hitElement and getElementType(hitElement)=="vehicle") then if getElementHealth(hitElement) >= 1000 then return end setElementHealth(hitElement, getElementHealth(hitElement)+100) end end addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc ) givePlayerMoney You've helped me a lot! Link to comment
Castillo Posted April 7, 2012 Share Posted April 7, 2012 @Blazy: Use triggerServerEvent to give the money, because if you give it client side it won't sync it. Link to comment
Wei Posted April 7, 2012 Author Share Posted April 7, 2012 Doesn't work. Server: function givemoney(thePlayer) givePlayerMoney( thePlayer, 1000 ) end addEvent( "givemoney", true ) addEventHandler( "givemoney", thePlayer, givemoney ) Client function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) if (weapon == 41 and hitElement and getElementType(hitElement)=="vehicle") then if getElementHealth(hitElement) >= 1000 then return end setElementHealth(hitElement, getElementHealth(hitElement)+100) triggerServerEvent ( "givemoney", getLocalPlayer()) end end addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc ) Link to comment
Castillo Posted April 7, 2012 Share Posted April 7, 2012 function givemoney ( ) givePlayerMoney ( source, 1000 ) end addEvent( "givemoney", true ) addEventHandler( "givemoney", root, givemoney ) Link to comment
Wei Posted April 7, 2012 Author Share Posted April 7, 2012 Now it gives me 3000$ why ? (FIXED) But there is 1 bug more. When Player is in the car it doesn't Repair car. But gives me money. Link to comment
Jaysds1 Posted April 8, 2012 Share Posted April 8, 2012 addEventHandler ( "onClientPlayerWeaponFire", localPlayer,function(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) if (weapon == 41 and hitElement and getElementType(hitElement)=="vehicle") then if getElementHealth(hitElement) >= 1000 then return end setElementHealth(hitElement, getElementHealth(hitElement)+100) fixVehicle(hitElement) triggerServerEvent ( "givemoney", getLocalPlayer()) end end) Link to comment
Kenix Posted April 8, 2012 Share Posted April 8, 2012 addEventHandler( "givemoney", thePlayer, givemoney ) lol? Your attach element ( thePlayer ) here is nil. https://wiki.multitheftauto.com/wiki/AddEventHandler Link to comment
Wei Posted April 8, 2012 Author Share Posted April 8, 2012 Thanks. Solved that. I didn't want to open new post so i'm asking here. Why it doesn't open the window? window = guiCreateWindow(325,111,482,473,"SHG User Panel",false) guiWindowSetSizable(window,false) grid1 = guiCreateGridList(242,30,228,347,false,window) guiGridListSetSelectionMode(grid1,2) guiGridListAddColumn(grid1,"Player Name",0.2) guiGridListAddColumn(grid1,"Wanted",0.2) guiSetAlpha(grid1,0.69999998807907) pinunpinplayer = guiCreateButton(250,392,215,69,"Pin / Unpin Player",false,window) EDchat = guiCreateButton(22,33,210,69,"Enable / Disable Chat",false,window) becomecivilanB = guiCreateButton(24,270,210,69,"Become civilan",false,window) suicideB = guiCreateButton(25,192,210,69,"Suicide",false,window) EDhud = guiCreateButton(23,112,210,69,"Enable / Disable Hud",false,window) shglabel = guiCreateLabel(57,372,138,61,"SHG",false,window) guiSetFont(shglabel,"sa-gothic") function resourceStart () bindKey ("F4", "down", menuShow) end addEventHandler ("onClientResourceStart", getResourceRootElement ( getThisResource () ), resourceStart) function menuShow () visableornot = guiGetVisible (window) if (visableornot == true) then guiSetVisible (window, false) showCursor (false) end if (visableornot == false) then guiSetVisible (window, true) showCursor (true) end end Link to comment
Kenix Posted April 8, 2012 Share Posted April 8, 2012 window = guiCreateWindow(325,111,482,473,"SHG User Panel",false) guiWindowSetSizable(window,false) grid1 = guiCreateGridList(242,30,228,347,false,window) guiGridListSetSelectionMode(grid1,2) guiGridListAddColumn(grid1,"Player Name",0.2) guiGridListAddColumn(grid1,"Wanted",0.2) guiSetAlpha(grid1,0.69999998807907) pinunpinplayer = guiCreateButton(250,392,215,69,"Pin / Unpin Player",false,window) EDchat = guiCreateButton(22,33,210,69,"Enable / Disable Chat",false,window) becomecivilanB = guiCreateButton(24,270,210,69,"Become civilan",false,window) suicideB = guiCreateButton(25,192,210,69,"Suicide",false,window) EDhud = guiCreateButton(23,112,210,69,"Enable / Disable Hud",false,window) shglabel = guiCreateLabel(57,372,138,61,"SHG",false,window) guiSetFont(shglabel,"sa-gothic") guiSetVisible( window, false ) function menuShow () guiSetVisible( window, not guiGetVisible( window ) ) showCursor( not isCursorShowing( ) ) end bindKey ("F4", "down", menuShow ) 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