Burak5312

Members
  • Content Count

    18
  • Joined

  • Last visited

Everything posted by Burak5312

  1. maybe this work function FORCE_PLAYER_WALK( player, condition ) if( condition == true ) then bindKey(player, "w", "down", function() setControlState(player, "walk", true) setControlState(player, "forwards", true) end) bindKey(player, "w", "up", function() setControlState(player, "walk", false) setControlState(player, "forwards", false) end) toggleControl( player, "sprint", false ) toggleControl( player, "forwards", false ) toggleControl( player, "backwards", false ) toggleControl( player, "left", false ) toggleControl( player, "right", false ) elseif( condition == false ) then toggleControl( player, "sprint", true ) toggleControl( player, "forwards", true ) toggleControl( player, "backwards", true ) toggleControl( player, "left", true ) toggleControl( player, "right", true ) unbindKey( player, "w", "down" ) unbindKey( player, "w", "up" ) else return nil end end addCommandHandler("force", function( player ) FORCE_PLAYER_WALK( player, true ) end ) addCommandHandler("forceend", function( player ) FORCE_PLAYER_WALK( player, false ) end )
  2. hello how can i detect when serverside ped damaged by player my purpose is ped turn face player and run if player not inside range function findRotation( x1, y1, x2, y2 ) local t = -math.deg( math.atan2( x2 - x1, y2 - y1 ) ) return t < 0 and t + 360 or t end function createTank( x, y, z ) if not (x) or not (y) or not (z) then return false end local THE_TANK = createPed( 0, x, y, z ) local tankX, tankY, tankZ = getElementPosition( THE_TANK ) local DETECT_RANGE = createColSphere( tankX, tankY, tankZ, 50 ) local BLIP = createBlipAttachedTo ( THE_TANK, 23 ) setBlipVisibleDistance( BLIP, 130 ) attachElements( DETECT_RANGE, THE_TANK ) local DETECT_TIMER = nil local TARGET_PLAYER = nil local FINDWAY_TIMER = nil if ( TARGET_PLAYER == nil ) then setTimer(function() setPedAnimation( THE_TANK, "ped", "idle_hbhb", -1, true, false, false, false ) end, 50, 1) end local function findWay() local tankX, tankY,_ = getElementPosition( THE_TANK ) local playerX, playerY,_ = getElementPosition( TARGET_PLAYER ) setElementRotation( THE_TANK, 0, 0, findRotation(tankX, tankY, playerX, playerY), "default", true ) end local function checkAround() if ( FINDWAY_TIMER == nil ) and ( TARGET_PLAYER == nil ) then local players = getElementsByType("player") for key, player in ipairs(players) do if( isElementWithinColShape(player, DETECT_RANGE ) ) then TARGET_PLAYER = player FINDWAY_TIMER = setTimer( findWay, 200, 0 ) return true end end end end DETECT_TIMER = setTimer(checkAround, 2000, 0) -- HERE!!! addEventHandler("onPedDamage", THE_TANK, function( attacker, attackerweapon, bodypart, loss ) if( attacker ) and ( getElementType(attacker) == "player" ) and ( TARGET_PLAYER == nil ) and ( FINDWAY_TIMER ==nil ) then TARGET_PLAYER = attacker FINDWAY_TIMER = setTimer(findWay, 200, 0) end end ) end createTank( 1942.90063, -1706.56201, 13.38281 )
  3. hello there a way to show a client side ped to another player? or is this just done as server side? my purpose show one player around zombies other player thank you
  4. thanks man worked! actually i write getter setters client version will be better thank you
  5. hello im trying call text with triggerClientEvent but saying ERROR: server triggered clientside event showHUD but event not is not added clientside and my client side code draw nil on the screen im trying to 58.line in server side my purpose is transfer server side data to client side client local screenW, screenH = guiGetScreenSize() function EXP_HUD(exp) dxDrawText( tostring( exp ), screenW/2, screenH/2, screenW/2, screenH/2, tocolor( 255,255,255,255 ), 1, "bankgothic", "center", "center" ) end addEventHandler("onClientRender", root, EXP_HUD) addEvent( "showHUD", true ) addEventHandler( "showHUD", localPlayer, EXP_HUD ) server function math.round( number ) return number - number % 1 end --====================================================================+ --INFO: Setter Getter Functions EXP AND LEVEL --====================================================================+ function getRequiredEXP( level ) if not ( level ) then return false end return math.round( math.pow( level, 2 ) * 300 ) end function getPlayerEXP( player ) if not ( player ) then return false end return getElementData( player, "ZR_EXP" ) end function setPlayerEXP( player, value ) if not ( player or value ) then return false end return setElementData( player, "ZR_EXP", tonumber( value ) ) end function getPlayerLevel( player ) if not ( player ) then return false end return getElementData( player, "ZR_LEVEL" ) end function setPlayerLevel( player, newlevel ) if not ( player or newlevel ) then return false end return setElementData( player, "ZR_LEVEL", tonumber( newlevel ) ) end function level_UP( player ) if not (player) then return false end local mylevel = getPlayerLevel( player ) local myexp = getPlayerEXP( player ) local required = getRequiredEXP( mylevel ) if myexp >= required then while myexp >= required do setPlayerLevel( player, mylevel + 1 ) outputChatBox( getPlayerLevel( player ) ) required = getRequiredEXP( mylevel + 1 ) outputChatBox( required ) end end end function addEXP( player, value ) if not ( player or value ) then return false end local myexp = getPlayerEXP( player ) setPlayerEXP( player, myexp + tonumber( value ) ) level_UP( player ) end function callHUD() local myexp = getPlayerEXP( source ) triggerClientEvent( source, "showHUD", source, myexp ) end -- initiliaze exp/level stuff addEventHandler( "onPlayerJoin", getRootElement(), function() setElementData(source, "ZR_LEVEL", 1) setElementData(source, "ZR_EXP", 0) callHUD( source ) end ) addCommandHandler( "getlevelexp", function( player ) local mylevel = getPlayerLevel( player ) local myexp = getPlayerEXP( player ) local required = getRequiredEXP( mylevel ) outputChatBox( "You Level: "..tostring( mylevel ) ) outputChatBox( "You EXP: "..tostring( myexp ) ) outputChatBox( "Need EXP: "..tostring( required ) ) end ) addCommandHandler("giveexp", function( player ) addEXP( player, 100 ) end )
  6. this time not be full exp bar when level up
  7. yes goes below 0 but i dont know how to fix this i spend my all day :d problem calculate formule? i tryed other methods but when level up exp bar staying half i need zero bar
  8. hello i need calculate between totalexp and requiredexp but i need reset exp bar when level up this bar disturb and backward like that 3 or 4 level help me please function math.round(number) return number - number % 1 end function getRequiredEXP(level) return math.round(math.pow(level, 2) * 300) end local level = 1 local currentEXP = 0 local totalEXP = 0 local requiredLevel = 0 local requiredEXP = getRequiredEXP(requiredLevel + 1) function DRAW_HUD() local percentageEXP = (currentEXP / requiredEXP) * 369 ---- formule dxDrawRectangle(1539, 914, 369, 5, tocolor(0, 0, 0, 255)) dxDrawRectangle(1539, 914, percentageEXP, 5, tocolor(255, 255, 255, 255)) dxDrawBorderedText(2, "LEVEL:", 1539, 942, 0, 0, tocolor(255,255,255,255), 1.50, "bankgothic") dxDrawBorderedText(2.5, level, 1722, 920, 0, 0, tocolor(255,255,255,255), 2.5, "bankgothic") dxDrawBorderedText(1.5, "EXP:", 1538, 860, 0, 0, tocolor(255,255,255,255), 1, "bankgothic") dxDrawBorderedText(1.5, totalEXP, 1538, 885, 0, 0, tocolor(255,255,255,255), 1, "bankgothic") if requiredEXP <= 999 then dxDrawBorderedText(1.5, " "..requiredEXP, 1538, 885, 0, 0, tocolor(255,255,255,255), 1, "bankgothic") elseif requiredEXP <= 9999 then dxDrawBorderedText(1.5, " "..requiredEXP, 1538, 885, 0, 0, tocolor(255,255,255,255), 1, "bankgothic") elseif requiredEXP <= 99999 then dxDrawBorderedText(1.5, " "..requiredEXP, 1538, 885, 0, 0, tocolor(255,255,255,255), 1, "bankgothic") elseif requiredEXP <= 999999 then dxDrawBorderedText(1.5, " "..requiredEXP, 1538, 885, 0, 0, tocolor(255,255,255,255), 1, "bankgothic") elseif requiredEXP <= 9999999 then dxDrawBorderedText(1.5, " "..requiredEXP, 1538, 885, 0, 0, tocolor(255,255,255,255), 1, "bankgothic") elseif requiredEXP <= 99999999 then dxDrawBorderedText(1.5, " "..requiredEXP, 1538, 885, 0, 0, tocolor(255,255,255,255), 1, "bankgothic") end end addEventHandler("onClientRender", root, DRAW_HUD) function dxDrawBorderedText (outline, text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI, colorCoded, subPixelPositioning, fRotation, fRotationCenterX, fRotationCenterY) for oX = (outline * -1), outline do for oY = (outline * -1), outline do dxDrawText (text, left + oX, top + oY, right + oX, bottom + oY, tocolor(122, 122, 122, 255), scale, font, alignX, alignY, clip, wordBreak, postGUI, colorCoded, subPixelPositioning, fRotation, fRotationCenterX, fRotationCenterY) end end dxDrawText (text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI, colorCoded, subPixelPositioning, fRotation, fRotationCenterX, fRotationCenterY) end function addEXP(amount) currentEXP = currentEXP + amount totalEXP = totalEXP + amount if totalEXP >= requiredEXP then currentEXP = currentEXP - requiredEXP level = level + 1 requiredLevel = requiredLevel + 1 requiredEXP = getRequiredEXP(requiredLevel + 1) end end addCommandHandler("giveexp", function() addEXP(80) end)
  9. hello when I logging in this script my hud is visible but reconnect and login after never see my hud help please if i restart this resource visible only one time i check with ZR:ShowMyHud visible setFPSLimit(60) function gInit_join() setCameraMatrix(source, 0, 0, 400, 90, 360, 180, 0) toggleControl(source, "radar", false) end addEventHandler("onPlayerJoin", getRootElement(), gInit_join) function gInit_login(_, theCurrentAccount) local playerEXP = getAccountData(theCurrentAccount, "ZR:EXP") local playerLevel = getAccountData(theCurrentAccount, "ZR:Level") setElementData(source, "ZR:EXP", playerEXP) setElementData(source, "ZR:Level", playerLevel) setElementData(source, "ZR:ShowMyHud", true) fadeCamera(source, true) showCursor(source, false) end addEventHandler("onPlayerLogin", getRootElement(), gInit_login) function gInit_saveaccount() local accounts = getPlayerAccount(source) if (accounts) then local EXP = getElementData(source, "ZR:EXP") local Level = getElementData(source, "ZR:Level") setAccountData(accounts, "ZR:EXP", EXP) setAccountData(accounts, "ZR:Level", Level) setElementData(source, "ZR:ShowMyHud", false) end end addEventHandler("onPlayerQuit", getRootElement(), gInit_saveaccount) function gInit_restart() local players = getElementsByType("player") for key, player in ipairs(players) do local account = getPlayerAccount(player) if (not isGuestAccount(account)) then logOut(player) end setElementData(player, "ZR:ShowMyHud", false) end end addEventHandler("onResourceStart", getResourceRootElement(), gInit_restart) function gInit_account(username, password) if (username and password) then local hashedPassword = passwordHash(password, "bcrypt", {}) if (hashedPassword) then local account = addAccount(username, hashedPassword) if (account) then setAccountData(account, "hash_password", hashedPassword) setAccountData(account, "ZR:Level", 5) setAccountData(account, "ZR:EXP", 3533) outputChatBox("REGISTER: Account successfuly created!", source, 0, 128, 0) else outputChatBox("REGISTER: Account already exists.", source, 255, 71, 61) end end end gInit_loginplayer(username, password) end addEvent("AcceptPlayer", true) addEventHandler("AcceptPlayer", root, gInit_account) function gInit_loginplayer(username, password) if (username and password) then local account = getAccount(username) if (account) then local hashedPassword = getAccountData(account, "hash_password") if (passwordVerify(password, hashedPassword)) then if logIn(source, account, hashedPassword) then triggerClientEvent(source, "removePanel", source) setElementData(source, "ZR:ShowMyHud", true) end else outputChatBox("REGISTER: Username or Password is incorrect.", source, 255, 71, 61) end end else outputChatBox("REGISTER: Account doesn't exists.", 255, 71, 61) end end addEvent("loginPlayer", true) addEventHandler("loginPlayer", root, gInit_loginplayer) function gInit_logoutplayer(_, theCurrentAccount) local exp = getElementData(source, "ZR:EXP") local level = getElementData(source, "ZR:Level") setAccountData(theCurrentAccount, "ZR:EXP", exp) setAccountData(theCurrentAccount, "ZR:Level", level) end addEventHandler("onPlayerLogout", root, gInit_logoutplayer)
  10. actually i scripting a kind zone game and i need make clean map and i need disable scale because distrupt text on the map
  11. yes i need to disable info text and scaling
  12. hi how to make a disable f11 scale map and remove top text? i searched but not finded
  13. Burak5312

    warnings

    @MrTasty hm okey thanks again
  14. Burak5312

    warnings

    @MrTasty thanks for answer i solved problem but 2 eventhandler make me trouble? performance lost or something?
  15. Burak5312

    warnings

    hello my code working good but giving warning like that thank you and i have questions 1- possible this function export as textlibrary? 2- and this code correct? text_c.Lua local x,y = guiGetScreenSize() local a = 255 function drawText() dxDrawText("LEVEL UP!", x/2, y/2, x/2, y/2, tocolor(255,255,255,255), 2, "bankgothic", "center", "center") fadetimer = setTimer(function() removeEventHandler("onClientRender", root, drawText) if(isTimer(fadetimer)) then killTimer(fadetimer) end addEventHandler("onClientRender", root,fadeText) end, 5000, 1) function fadeText() if not (a == 0) then dxDrawText("LEVEL UP!", x/2, y/2, x/2, y/2, tocolor(255,255,255,a), 2, "bankgothic", "center", "center") a = a - 5 destroytimer = setTimer(function() removeEventHandler("onClientRender", root, fadeText) if(isTimer(destroyTimer)) then killTimer(destroytimer) end end, 8000, 1) end end end addEventHandler("onClientRender", root, drawText)
  16. hello I have a problem i create ped /boomer command following player but rejoin server ped wont move server function spawnBoomer(thePlayer) playerX, playerY, playerZ = getElementPosition(thePlayer) boomer = createPed(114, playerX + 5, playerY, playerZ) local bX, bY, bZ = getElementPosition(boomer) myBlip = createBlipAttachedTo(boomer, 23) exports.extra_health:setElementExtraHealth(boomer, 2000) function OnPedWasted () if ( isPedDead ( boomer) ) then x, y, z = getElementPosition(boomer) createExplosion(x, y, z, 11) destroyElement(boomer) destroyElement(myBlip) triggerClientEvent ( thePlayer, "pedWasted", thePlayer, x, y, z ) end end addEventHandler("onPedWasted", boomer, OnPedWasted ) function BoomerDirectionUpdate() local pX,pY,pZ = getElementPosition(thePlayer) local bX,bY,bZ = getElementPosition(boomer) if(not isPedDead(boomer)) then triggerClientEvent(thePlayer, "BoomerDirection", thePlayer, boomer, pX ,pY ,pZ ,bX ,bY ,bZ) end end setTimer(BoomerDirectionUpdate,50,0) function BoomerStartFollow() local pX,pY,pZ = getElementPosition(thePlayer) local bX,bY,bZ = getElementPosition(boomer) if(not isPedDead(boomer)) then triggerClientEvent(thePlayer, "BoomerStartRun", thePlayer, boomer, pX ,pY ,pZ ,bX ,bY ,bZ) end end setTimer(BoomerStartFollow,50,0) end addCommandHandler("boomer", spawnBoomer) function skinBoomer() txd = engineLoadTXD ("boomer.txd") engineImportTXD ( txd, 114 ) dff = engineLoadDFF ("boomer.dff") engineReplaceModel (dff, 114) end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),skinBoomer) function boomerDeathExplode( x, y, z ) fxAddDebris(x, y, z, 255, 0, 0, 255, 0.1, 200) end addEvent( "pedWasted", true ) addEventHandler( "pedWasted", localPlayer, boomerDeathExplode) function BoomerDirectionHandler(boomer) local pX,pY,pZ = getElementPosition(localPlayer) local bX,bY,bZ = getElementPosition(boomer) local distance = getDistanceBetweenPoints3D(pX, pY, pZ, bX, bY, bZ) if(distance < 30) then intPedRot = -math.deg (math.atan2(pX - bX, pY - bY)) if intPedRot < 0 then intPedRot = intPedRot + 360 end; setElementRotation (boomer, 0, 0, intPedRot, 'default', true) end end addEvent("BoomerDirection", true) addEventHandler("BoomerDirection", localPlayer, BoomerDirectionHandler) function BoomerRunPunch(boomer) local pX,pY,pZ = getElementPosition(localPlayer) local bX,bY,bZ = getElementPosition(boomer) local distance = getDistanceBetweenPoints3D(pX, pY, pZ, bX, bY, bZ) if(distance < 50) then setPedControlState(boomer, "forwards", true) else setPedControlState(boomer, "forwards", false) end end addEvent("BoomerStartRun", true) addEventHandler("BoomerStartRun", localPlayer, BoomerRunPunch) client