Jump to content

AJXB

Members
  • Posts

    367
  • Joined

  • Last visited

Posts posted by AJXB

  1. Many ways to do that, but you can just go on the wiki and look for an ACL function that checks that.

    I can tell you what function that is but you should spend some time :)

  2. You can just make a function rather than making an event since they're both on the server side.

    function onZombieWasted (attacker)
    	if (isElement( attacker )) then
        	givePlayerMoney(attacker,math.random(75,150))   -- default 50$
        end
    end	
    
    function deanimated( ammo, attacker, weapon, bodypart )
    	if (attacker) then
    		if (getElementType ( attacker ) == "player") and (getElementType ( source ) == "ped") then
    			if (getElementData (source, "zombie") == true) then
    				local oldZcount = getElementData ( attacker, "Zombie kills" )
    				if oldZcount ~= false then
    					setElementData ( attacker, "Zombie kills", oldZcount+1  )
    				else
    					setElementData ( attacker, "Zombie kills", 1  )		
    				end
    				onZombieWasted ( attacker )
    			end
    		end
    	end
    
    end
    addEventHandler("onPedWasted", resourceRoot, deanimated)

    You might wanna add a check to the weapon used, to avoid abuse

  3. Line 4 is checking for data related to the player, It's there because the script is taken from another game mode, or considered connected to other scripts.

    Replace line 4 with this line and post any errors you have

    if (isElement( thePlayer )) then

    Next time, please write your own code

  4. 16 hours ago, Khadeer143 said:

    What's the use of this ? Its just a forum nothing else 

    It's even more useless than a forum, it's just a theme

     

    12 hours ago, iSubvibe said:

    Its Invision Power Suit IPS.

    And how much are you thinking this is worth?

  5. the pistol fires 1 projectile (bullet) and the sawed-off fires many? Not sure, but it will depend on where are you shooting the ped too. maybe someone else can be more of a help

    • Thanks 1
  6. 1 minute ago, Khadeer143 said:

    Run debug script and check the errors 

    He did, that's how he found the errors above.

    I think he removed `addCommandHandler` and changed the player instance

  7. Try this:

     

    -- Server Side
    
    damageTimers = {}
    
    function handlePlayerDamage ( attacker, weapon, bodypart, loss ) 
    	if (attacker) then -- Check if an attacker exists, you might wanna add a check to see if it's a valid player, also check the attacked player (source)
    		if isTimer(damageTimers[source]) then -- Check if there is already a timer to reset the state of that player, happens when the player is damaged again before the 20 seconds are over
    			killTimer(damageTimers[source]) -- Kill the old timer and continue to make a new one
    		end
    		setElementData(source,'damaged',true) -- Mark the player as damaged within the last 20 seconds
    		damageTimers[source] = setTimer( -- Make a timer, we used a table damageTimers[]
    			function()
    				setElementData(source,'damaged',false) -- Mark the player as not damaged within the last 20 seconds AFTER the timer expires (20 seconds)
    			end, 20*1000, 0
    		)
    	end
    end
    addEventHandler ( "onPlayerDamage", getRootElement (), handlePlayerDamage ) -- addEventHandler to all players

     

  8. Try this:

    -- Client
    
    window1 = guiCreateWindow(455, 178, 710, 532, "", false)
    editUsername = guiCreateEdit(167, 108, 361, 40, "", false, window1)
    editPassword = guiCreateEdit(170, 197, 358, 36, "", false, window1)
    btnLogin = guiCreateButton(9, 434, 691, 43, "Login", false, window1)
    btnClose = guiCreateButton(14, 486, 686, 36, "Close", false, window1)    
    guiSetVisible(window1, true)
    showCursor(true)
    guiWindowSetSizable(window1, false)
    
    function closeGui() 
    	if btnClose == source then
    		guiSetVisible(window1, false)
    		showCursor(false)
      	end 
    end 
    addEventHandler("onClientGUIClick", root, closeGui) -- changed "root"
    
    function logToServer()
    	if (source == btnLogin) then -- Check button clicked
    		local account = guiGetText(editUsername)
    		local password = guiGetText(editPassword)
    		local name = getPlayerName(getLocalPlayer())
    		triggerServerEvent("test", localPlayer, account, password, name)
    	end
    end 
    addEventHandler("onClientGUIClick", root, logToServer) -- changed "root"
    
    -- Server
    
    function myMoney(account, password, name)
    	outputChatBox(name);
    	logIn (source, account, password) 
    end
    addEvent("test", true)
    addEventHandler("test", root, myMoney)

     

  9. 4 minutes ago, DeadthStrock said:

    Quoted :- https://wiki.multitheftauto.com/wiki/GuiCreateButton

    
    --create our button
    button = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Output!", true )
    --Create an edit box and define it as "editBox".
    editBox = guiCreateEdit( 0.3, 0.1, 0.4, 0.1, "Type your message here!", true )
    -- and attach our button to the outputEditBox function
    addEventHandler ( "onClientGUIClick", editBox, outputEditBox )
    guiEditSetMaxLength ( editBox, 128 ) --the max chatbox length is 128, so force this
    
    --setup our function to output the message to the chatbox
    function outputEditBox ()
            local text = guiGetText ( editBox )--get the text from the edit box
            outputChatBox ( text ) --output that text
    end
    addEventHandler ( "onClientGUIClick", button, outputEditBox )
    

              MTA:Wiki also guide that...!! Well Well as you said Compatibility may issues if we put the GUI element in the event handler.

     

    Yep, and I still stand by word. 

    the GUI sometimes calculates the actual button element a bit larger than the actual displayed unit, or since it's attached to the GUI window, it sometimes confuses that as well. So that means when you click outside of a button, it triggers the button.

    Feel free to use any method you like, but what I use to avoid any type of issue is the first solution.

  10. 1 minute ago, SSKE said:

    Mate I wanted to change from false to true in warp_event but I fix it anyway thanks

    You made a topic to ask someone to fix "your" script, which would be fixed if you changed false to true? :)

×
×
  • Create New...