Jump to content

Saml1er

Retired Staff
  • Posts

    1,058
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Saml1er

  1. Those lines are causing it: 251. local rdmangle = math.random(1, 359) 252. setPedRotation(ped, rdmangle) 253. triggerClientEvent("onZombieControl", ped, "stop") 254. triggerClientEvent("onZombieControl", ped, "walk") Can you show onZombieControl event? you might be setting 2 control states in a row.
  2. Are those relative sizes? I think you haven't posted the full script. O_o Anyway check this out: viewtopic.php?f=91&t=82677&p=753736#p753736 This is how you do it. local Auflosung_x , Auflosung_y = guiGetScreenSize() local fontSize = 1.15/1920*Auflosung_x dxDrawText ( string.format("%.0f",distance) .. " m", Auflosung_x*0.4 , Auflosung_y*0.3 , Auflosung_x*0.2, Auflosung_y*0.3 , tocolor ( 255, 255, 255, 255 ), fontSize, "default-bold", "right", "bottom" )
  3. Hmmm.... That's weird. I'll test the code tomorrow.
  4. Saml1er

    Mutiple skins

    onPlayerSpawn is server side event. Use addEventHandler ( "onClientPlayerSpawn", localPlayer, randomwehicle ) Also you can drive client side created vehicles. So you must create vehicle server side and use math.random. local text = { {"bobcat1.txd" , "bobcat1.dff",422} , {"bobcat2.txd" , "bobcat2.dff",422} } local ran = math.random ( 1,#text } local txd = engineLoadTXD ( text[ran][1] ) engineImportTXD ( txd, text[ran][3] ) local dff = engineLoadDFF(text[ran][2], text[ran][3]) engineReplaceModel(dff, text[ran][3])
  5. Seems you messed up something. Anyway I have a fixed version. exports["scoreboard"]:addScoreboardColumn("zombieKills", root, 80, "Zombmoanie-Kills",80) local ZombiePedSkins = {22,56,67,68,69,70,84,92,97,105,107,108,111,126,127,128,152,162,167,188,192,195,206,209,212,229,230,258,264,274,277} --ALTERNATE SKIN LISTS FOR ZOMBIES (SHORTER LIST IS TEXTURED ZOMBIES ONLY) local ZombieLimit = 50 -- HOW MANY ZOMBIES SHOULD EXIST AT MAXIMUM? local ZombieStreaming = 1 -- 1 to constantly stream zombies, 0 to only allow zombies to spawn via createZombie function, 2 to only allow spawning at set spawnpoints local ZombieSpeedCheck = 400 local chaseanim = "run_old" local checkspeed = 500 local count = 0 local moanlimit = 10 local everyZombie = { } local zombieblip = { } --RESOURCE START/INITIAL SETUP addEventHandler("onResourceStart", resourceRoot, function ( ) local timer = ZombieSpeedCheck for _,thePlayer in ipairs(getElementsByType("player")) do setElementData(thePlayer, "dangercount", 0) end MainTimer1 = setTimer(setangle, timer, 0) -- KEEPS ZOMBIES FACING THE RIGHT DIRECTION MainTimer3 = setTimer(triggerEvent, 3000, 0, "onClearFarZombies", root) --KEEPS ALL THE ZOMBIES CLOSE TO PLAYERS MainTimer2 = setTimer(triggerEvent, 2500, 0, "onPreZombieSpawn", root, 2500, 0) --Spawns zombies in random locations end) --SETS THE ZOMBIE ACTIVITY WHEN STATUS CHANGES addEventHandler("onElementDataChange", root, function (dataName) if (getElementType(source) == "ped") and (dataName == "status") then if (getElementData(source, "zombie")) then if not (isPedDead(source)) then if (getElementData(source, "status") == "chasing") then local Zx, Zy, Zz = getElementPosition(source) local newtarget = getElementData(source, "target") if (isElement(newtarget)) then if (getElementType(newtarget) == "player") then setElementSyncer(source, newtarget) end Zx, Zy, Zz = getElementPosition(newtarget) end setTimer(setZombieChase, 1000, 1, source, Zx, Zy, Zz) elseif (getElementData(source, "status") == "idle") then setTimer(setZombieIdle, 1000, 1, source) --[[elseif (getElementData ( source, "status" ) == "throatslashing" ) then local tx,ty,tz = getElementPosition( source ) local ptarget = getElementData ( source, "target" ) if isElement(ptarget) then local vx,vy,vz = getElementPosition( ptarget ) local zombdistance = (getDistanceBetweenPoints3D (tx, ty, tz, vx, vy, vz)) if (zombdistance < . then triggerClientEvent("onZombieControl", source, "moan", math.random(moanlimit)) setPedAnimation ( source, "knife", "KILL_Knife_Player", -1, false, false, true) setPedAnimation ( ptarget, "knife", "KILL_Knife_Ped_Damage", -1, false, false, true) setTimer ( Playerthroatbitten, 2300, 1, ptarget, source) setTimer ( function (source) if ( isElement ( source ) ) then setElementData ( source, "status", "idle" ) end end, 5000, 1, source ) else setElementData ( source, "status", "idle" ) end else setElementData ( source, "status", "idle" ) end]] end elseif (getElementData(source, "status") == "dead") then setTimer(destroyElement, 10000, 1, source) end end end end) --CLEARS A DEAD ZOMBIE addEventHandler("onElementDestroy", resourceRoot, function ( ) if (getElementType(source) == "ped") and (getElementData(source, "zombie")) then for theKey,thePed in ipairs(everyZombie) do if (source == thePed) then table.remove(everyZombie, theKey) break end end if (zombieblip[source]) then destroyElement(zombieblip[source]) zombieblip[source] = nil end end end) --DELETES ZOMBIES THAT ARE TOO FAR FROM ANY PLAYERS TO KEEP THEM MORE CONCENTRATED WHILE STREAMING ZOMBIES addEvent("onClearFarZombies", true ) addEventHandler("onClearFarZombies", root, function () if (ZombieLimit) then local toofarzombies = { } local allplayers = getElementsByType("player") for ZombKey,theZomb in ipairs(everyZombie) do if isElement(theZomb) then if (getElementData (theZomb, "zombie") == true) then local Zx, Zy, Zz = getElementPosition( theZomb ) for theKey,thePlayer in ipairs(allplayers) do local Px, Py, Pz = getElementPosition(thePlayer) local distance = getDistanceBetweenPoints3D(Px, Py, Pz, Zx, Zy, Zz) if (distance > 75) then if not (getElementData(theZomb, "forcedtoexist")) then destroyElement(theZomb) end end end if far == 1 then table.insert( toofarzombies, theZomb ) end end else table.remove(everyZombie, ZombKey) end end end end) --HEADSHOTS addEvent("headboom", true) addEventHandler("headboom", root, function (ped,attacker, weapon, bodypart) if (getElementData(ped, "zombie") == true) then killPed(ped, attacker, weapon, bodypart) setPedHeadless(ped, true) end end) --KILL FROM ZOMBIE ATTACK addEvent("onZombieKillPlayer", true ) addEventHandler("onZombieKillPlayer", getRootElement(), function (player, weapon, bodypart) killPed(player, source, weapon, bodypart) end) --CHECKS FOR ZOMBIE GRABBING FROM BEHIND function Playerthroatbitten ( player, attacker) local Zx, Zy, Zz = getElementPosition( attacker ) local Px, Py, Pz = getElementPosition( player ) local distance = (getDistanceBetweenPoints3D( Px, Py, Pz, Zx, Zy, Zz )) if (distance < 1) then killPed ( player, attacker, weapon, bodypart ) else setPedAnimation (player) end end --ADJUSTS PLAYERS ZOMBIE KILL SCORE addEventHandler("onPedWasted", resourceRoot, function (ammo, attacker, weapon, bodypart) if (attacker) then if (getElementType ( attacker ) == "player") and (getElementType ( source ) == "ped") then if (getElementData (source, "zombie") == true) then triggerEvent ( "onZombieWasted", source, attacker, weapon, bodypart ) local zkill = exports["ZA-export"]:getPlayerZKill(attacker) if (zkill) then local attackerName = getPlayerName(attacker) local ar, ag, ab = getPlayerNametagColor(attacker) setElementData(attacker, "zombieKills", zkill+1) exports["ZA-account"]:setAccountData(attacker, "zombieKills", zkill+1) givePlayerMoney(attacker, math.random(100,300)) exports["ZA-level"]:givePlayerExp(attacker, math.random(2,10)) exports.killmessages:outputMessage({attackerName,{"padding",width=3},{"icon",id=weapon or 0},{"padding",width=3},{"color",r=162,g=0,b=0},"Zombie"}, getRootElement(), ar, ag, ab) end end end end end) addEventHandler("onPlayerLogin", getRootElement(), function (_,account) local zombieKills = exports["ZA-account"]:getAccountData(source, "zombieKills") if (zombieKills) then setElementData(source, "zombieKills", zombieKills) end end) addEventHandler("onVehicleStartEnter", root, function (thePlayer) if (exports["ZA-export"]:isPlayerInTeam(thePlayer, "Zombies")) then cancelEvent() exports["ZA-hud"]:createNewHelpMessageForPlayer(enteringPlayer,"You'r zombie stupid don't know how to drive", 255, 0, 0) end end) --SPAWN ZOMBIE (now can be cancelled!) addEvent("onZombieSpawn", true ) addEventHandler("onZombieSpawn", root, function (gx, gy, gz, rot) if not hasPositionZombieProof(gx, gy) and (#everyZombie < ZombieLimit) then local rot = rot or math.random(360) local skin = tonumber(ZombiePedSkins[math.random(#ZombiePedSkins)]) local zombie = createPed(skin, gx, gy, gz, rot) if (zombie) then zombieblip[zombie] = createBlipAttachedTo(zombie, 0, 1, 160, 0, 0, 255, 0, 100) setElementData(zombie, "zombie", true) setElementData(zombie, "status", "idle") setPedWalkingStyle(zombie, 120) table.insert(everyZombie, zombie) triggerClientEvent("onZombieControl", zombie, "moan", math.random(moanlimit)) triggerClientEvent("onZombieControl", zombie, "stfu") end end end) --SPAWNS ZOMBIES RANDOMLY NEAR PLAYERS addEvent("onPreZombieSpawn", true ) addEventHandler("onPreZombieSpawn", root, function () local pacecount = 0 while pacecount < 5 do --4 ZOMBIES AT A TIME TO PREVENT FPS DROP local tzombiecount = #everyZombie+pacecount if (tzombiecount < ZombieLimit) then local livePlayers = getAlivePlayers() if (#livePlayers > 0) then local lowestcount, lowestguy = 99999, nil for _, thePlayer in ipairs(livePlayers) do local dangercount = getElementData(thePlayer, "dangercount") or 0 if (dangercount < lowestcount) and not (getElementData(thePlayer, "zombieProof")) then local gx, gy, gz = getElementPosition(thePlayer) if not hasPositionZombieProof(gx, gy) then lowestcount, lowestguy = dangercount, thePlayer end end end pacecount = pacecount+1 if (isElement(lowestguy)) then local disc, angle = math.random(15, 50), math.random(360) local ycoord, xcoord = getDistanceRotation(0, 0, disc, angle) triggerClientEvent("onClientPreZombieSpawn", lowestguy, ycoord, xcoord) else pacecount = pacecount+1 end else pacecount = pacecount+1 end else pacecount = pacecount+1 end end end) --IDLE BEHAVIOUR OF A ZOMBIE function setZombieIdle (ped) if (isElement(ped)) and not (isPedDead(ped)) then if (getElementData(ped, "status") == "idle") and (getElementData(ped, "zombie")) then local action = math.random(6) if (action > 2) then -- walk a random direction
  6. Why don't you post a tutorial? I mean guys simply keep asking the same question again and again. Your answer is quite detailed. I'm sure it will help many people. I had no idea how to calculate relative sizes in past but then figured it out after reading some examples... Wiki has already explained it: https://wiki.multitheftauto.com/wiki/GuiGetScreenSize But people hardly use their brains to understand wiki and depend on examples well that's humans for you.
  7. local health = (getElementHealth(vehicle)-250)/750*100 This will return health between 0 and 100.
  8. Saml1er

    Search...

    This? https://community.multitheftauto.com/ind ... ls&id=2602 If not then stary learning lua from today.
  9. You need to caculate relative sizes. Use the search option.
  10. I gave you a piece of code which will set volume of map music to 50%.
  11. Open race_client.lua in race resource and add this line in top. _playSound = playSound function playSound ( ... ) local sound = _playSound(...) if not sound then return false end setSoundVolume(sound, 0.5) return sound end
  12. Have you tried disabling the attached element's collision? Although setElementCollisionsEnabled is a little buggy but it will get the job done.
  13. You don't need a loop for such a small thing. local badWord = { [":O" ]= true , ["lol"] = true } local function getMessage(message, messageType) if messageType == 0 then if badWord[message] then killPed(source) end end end addEventHandler("onPlayerChat", getRootElement(), getMessage) EDIT: Fixed a typo.
  14. How are you creating the files? -- This will write in your download resource folder fileCreate("resourceName/file.txt") Have you tried this? -- This will write into deathmatch\resources fileCreate(":resourceName/file.txt")
  15. if level > 1 and cash > 10 then setTimer(createObject,2000,1,3374, x, y, z) givePlayerMoney ( thePlayer, -10 ) else outputChatBox("You need more cash or your level does not meet the requirements", source, 255, 255, 255, true) end
  16. Saml1er

    intro [Help]

    You'll also need to use this: dxCreateScreenSource dxUpdateScreenSource
  17. addEventHandler("onClientRender",root, function () dxSetAspectRatioAdjustmentEnabled( true ) -- Now call dx functions dxDrawText(...) end)
  18. Shanakht card ki details bhi poochte hain? Phir uss ke liye kya kiya?
  19. 18+ ho? Agar nahi tho phir sochna bhi mat. Meine payoneer ke admin se baat ki hain aur mujhe kaha ke iss ke liye aap ki age 18+ honi chahiye.
×
×
  • Create New...