Jump to content

Maurize

Members
  • Posts

    226
  • Joined

  • Last visited

Everything posted by Maurize

  1. No. Seems like that all is okay... I´ve uploaded some screens and the code. Code: local players=getElementsByType( "player" ) function refresh() players = getElementsByType( "player" ) end addEventHandler( "onClientPlayerQuit", getRootElement(), refresh ) addEventHandler( "onClientPlayerJoin", getRootElement(), refresh ) function NameTags() px, py, pz = getCameraMatrix() for k, v in ipairs( players ) do tx, ty, tz = getElementPosition( v ) dist = ( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2) ^ 0.5 if dist < 10 then if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, Spieler ) then sx, sy, sz = getPedBonePosition( v, 5 ) x,y = getScreenFromWorldPosition( sx, sy, sz + 0.3 ) armor = getPedArmor( v ) hp = getElementHealth( v ) / ( 1 + math.max( getPedStat( v, 24) - 569, 0 ) / 431 ) if armor then color = tocolor( 0, 0, armor * 1.5, 150 ) elseif hp > 50 then color = tocolor( 0, hp * 1.5, 0, 150 ) else color = tocolor( hp * 1.5, 0, 0, 150 ) end end dxDrawText( getPlayerName( v ), x, y, x + 200, y + 50, color, 0.85 + ( 15 - dist ) * 0.02, "pricedown" ) end end end addEvent( "NameTags", true ) addEventHandler( "NameTags", getRootElement(), function() addEventHandler( "onClientRender", getRootElement(), NameTags ) end ) Screens:
  2. Hey everybody, I tried to create a playerlist. I got 1 Problem: If I join server as first & alone all is shown correctly. But if a second player joins, my name is shown twice and his, too. So is there a way to debug this ? And maybe ideas how to make it better? Thanks & Greetings, Brasco local x, y = guiGetScreenSize() local pList = guiCreateGridList( x / 4, y / 4, 400, 400, false ) local pcol1 = guiGridListAddColumn( pList, "Name", 0.2 ) local pcol2 = guiGridListAddColumn( pList, "Gang", 0.2 ) local pcol3 = guiGridListAddColumn( pList, "Ping", 0.2 ) guiWindowSetMovable( pList, false ) guiWindowSetSizable( pList, false ) guiSetVisible( pList, false ) function PlayerList() if ( guiGetVisible( pList ) == false ) then for i = 0, guiGridListGetRowCount( pList ) do guiGridListRemoveRow( pList, i ) end guiSetVisible( pList, true ) for id, player in ipairs( getElementsByType( "player" ) ) do prow1 = guiGridListAddRow( pList ) guiGridListSetItemText( pList, prow1, pcol1, getPlayerName( player ), false, false ) guiGridListSetItemText( pList, prow1, pcol2, getTeamName( getPlayerTeam( player ) ), false, false ) guiGridListSetItemText( pList, prow1, pcol3, getPlayerPing( player ), false, false ) end else guiSetVisible( pList, false ) end end bindKey( "tab", "both", PlayerList )
  3. I only don´t understand why the text is only black, but only blue if I got armor equipped...
  4. Nice, Nice. Perfect BTW you forgot 1 end and some smaller bugs like "o" .. But you your method is very smart!
  5. ok will do. off-screen.. im useing fps at the same time. i´m trying something right now EDIT: Right. My FPS Script caused all this bugs, ect. I´m not that good in scripting. Can you show me a way to make this whole code smaller? Maybe local color = { ... } ? Thanks alot, mate!
  6. Hm. I got an error i cant understand. Maybe you can help me, community members. Line 19 : Bad Argument @ dxDrawText function NameTags() local px, py, pz, tx, ty, tz, dist px, py, pz = getCameraMatrix() for k, v in ipairs( getElementsByType( "player" ) ) do tx, ty, tz = getElementPosition( v ) dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2) if dist < 10 then if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, Spieler ) then local sx, sy, sz = getPedBonePosition( v, 5 ) local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.3 ) if ( getPedArmor( v ) <= 100 ) and ( getPedArmor( v ) > 75 ) then dxDrawText( getPlayerName( v ), x, y, x, y, tocolor( 0, 0, 200, 200 ), 0.85 + ( 15 - dist ) * 0.02, "pricedown" ) elseif ( getPedArmor( v ) <= 75 ) and ( getPedArmor( v ) > 50 ) then dxDrawText( getPlayerName( v ), x, y, x, y, tocolor( 0, 0, 150, 200 ), 0.85 + ( 15 - dist ) * 0.02, "pricedown" ) elseif ( getPedArmor( v ) <= 50 ) and ( getPedArmor( v ) > 25 ) then dxDrawText( getPlayerName( v ), x, y, x, y, tocolor( 0, 0, 100, 200 ), 0.85 + ( 15 - dist ) * 0.02, "pricedown" ) elseif ( getPedArmor( v ) <= 25 ) and ( getPedArmor( v ) > 0 ) then dxDrawText( getPlayerName( v ), x, y, x, y, tocolor( 0, 0, 50, 200 ), 0.85 + ( 15 - dist ) * 0.02, "pricedown" ) elseif ( getElementHealth( v ) <= 100 ) and ( getElementHealth( v ) > 90 ) then dxDrawText( getPlayerName( v ), x, y, x, y, tocolor( 0, 250, 0, 200 ), 0.85 + ( 15 - dist ) * 0.02, "pricedown" ) elseif ( getElementHealth( v ) <= 90 ) and ( getElementHealth( v ) > 80 ) then dxDrawText( getPlayerName( v ), x, y, x, y, tocolor( 0, 200, 0, 200 ), 0.85 + ( 15 - dist ) * 0.02, "pricedown" ) elseif ( getElementHealth( v ) <= 80 ) and ( getElementHealth( v ) > 70 ) then dxDrawText( getPlayerName( v ), x, y, x, y, tocolor( 0, 150, 0, 200 ), 0.85 + ( 15 - dist ) * 0.02, "pricedown" ) elseif ( getElementHealth( v ) <= 70 ) and ( getElementHealth( v ) > 60 ) then dxDrawText( getPlayerName( v ), x, y, x, y, tocolor( 0, 100, 0, 200 ), 0.85 + ( 15 - dist ) * 0.02, "pricedown" ) elseif ( getElementHealth( v ) <= 60 ) and ( getElementHealth( v ) > 50 ) then dxDrawText( getPlayerName( v ), x, y, x, y, tocolor( 0, 50, 0, 200 ), 0.85 + ( 15 - dist ) * 0.02, "pricedown" ) elseif ( getElementHealth( v ) <= 50 ) and ( getElementHealth( v ) > 40 ) then dxDrawText( getPlayerName( v ), x, y, x, y, tocolor( 50, 0, 0, 200 ), 0.85 + ( 15 - dist ) * 0.02, "pricedown" ) elseif ( getElementHealth( v ) <= 40 ) and ( getElementHealth( v ) > 30 ) then dxDrawText( getPlayerName( v ), x, y, x, y, tocolor( 100, 0, 0, 200 ), 0.85 + ( 15 - dist ) * 0.02, "pricedown" ) elseif ( getElementHealth( v ) <= 30 ) and ( getElementHealth( v ) > 20 ) then dxDrawText( getPlayerName( v ), x, y, x, y, tocolor( 150, 0, 0, 200 ), 0.85 + ( 15 - dist ) * 0.02, "pricedown" ) elseif ( getElementHealth( v ) <= 20 ) and ( getElementHealth( v ) > 10 ) then dxDrawText( getPlayerName( v ), x, y, x, y, tocolor( 200, 0, 0, 200 ), 0.85 + ( 15 - dist ) * 0.02, "pricedown" ) elseif ( getElementHealth( v ) <= 10 ) then dxDrawText( getPlayerName( v ), x, y, x, y, tocolor( 250, 0, 0, 200 ), 0.85 + ( 15 - dist ) * 0.02, "pricedown" ) end end end end end addEvent( "NameTags", true ) addEventHandler( "NameTags", Spieler, function() addEventHandler( "onClientRender", getRootElement(), NameTags ) end )
  7. Hello Community Members, I´ve created a little Skill like the player in Bioshock got. At first, I am creating a Fire Power. Players should be able to fire other players arround them. Please give me some hints what can be done better. And how can i get the closesest player? My Problem is, that my created table contains EVERY PLAYER ( the local player, too ). So the local player gets fired, too. Is there a way to remove the local player out of the table? Here my code: ****JR10 fixed Version****
  8. doesnt matter.. works perfectly.. use tiny explosion and pz+10..
  9. Do it exactly +10 over the player .. players won´t be able to move the mouse exactly to this point so they won´t see it..
  10. i knew a guy how finished this..he used the power of the camera xDD
  11. oh my holy shit.. it works.. You are the best maan! ( Only forgot to set it in meta to client ^^) BUT Now i always see this explosion.. can i make it invisible?? somethig like : getElement .. setVisibile ( 0,...
  12. I want that the whole screen rumbles when player shoots with a gun. In real the recoil would let the body of a human shake, so his eyes shake even. Only the player which shoots the weapon should see the rumble. .. thats what i try to get..
  13. noo.. even doesnt work .. look: function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip) local pX, pY, pZ = getElementPosition ( source ) if (weapon == 22) then createExplosion(pX, pY, pZ, 6, source) end end addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc)
  14. this is the point. i can´t find the right thing on Mta sa wiki. I need something like OnPlayerFire .. otherwise I must create a whole new event Isnt there something like: OnButtonDown or something ??
  15. So. I try to create an explosion when the player shoots.. I don´t know what i must add here.. i think i forgot it And yes i know its kinda copy of mta sa wiki cause this script isn´t much longer.. This script should let the shooting look like real. The screen must shake! function explosionOnShoot ( ) if *DONO WHAT I SHOULD WRITE HERE* then local pX, pY, pZ = getElementPosition ( source ) createExplosion ( pX, pY, pZ, 6, source ) end addEventHandler ( "onPlayerShoot", getRootElement(), explosionOnShoot )
  16. u need the ressource bank. then add the bank.locations file. So... Ben won´t come online next time. Try to survive without him
  17. addEventHandler("onResourceStart", resourceRoot, function() for i,player in ipairs(getElementsByType("player")) do spawn(player) end end ) function spawn(player) local playerTeam = getPlayerTeam ( player ) if ( getTeamName(playerTeam) == "Mercenaries" ) then spawnPlayer ( player, 2800.721, -2455.929, 13.630, 90, 179 ) fadeCamera(player, true) setCameraTarget(player, player) giveWeapon(player, 4, 68) giveWeapon(player, 22, 68) giveWeapon(player, 31, 100) giveWeapon(player, 18, 5) setPlayerStat ( thePlayer, 69, 999 ) setPlayerStat ( thePlayer, 78, 1000 ) setPlayerStat ( thePlayer, 24, 1000 ) setPlayerStat ( thePlayer, 23, 1000 ) elseif ( getTeamName(playerTeam) == "Police" ) then spawnPlayer ( player, 1580.233, -1636.650, 13.553, 90, math.random(280,281) ) fadeCamera(player, true) setCameraTarget(player, player) giveWeapon(player, 3, 1) giveWeapon(player, 22, 68) giveWeapon(player, 29, 120) setPlayerStat ( thePlayer, 69, 750 ) setPlayerStat ( thePlayer, 76, 1000 ) setPlayerStat ( thePlayer, 24, 1000 ) setPlayerStat ( thePlayer, 23, 1000 ) else spawnPlayer ( player, 2824.647+math.random(-0,5), -2438.673+math.random(-0,5), 13, 90, 177 ) fadeCamera(player, true) setCameraTarget(player, player) giveWeapon(player, math.random(2,7)) end end addEventHandler("onPlayerLogin", root, function() spawn(source) end ) addEventHandler("onPlayerWasted", root, function() setTimer(spawn, 5000, 1, source) end ) and the team script: function playerJoined() check(source) end addEventHandler("onPlayerJoin",getRootElement(),playerJoined) function playerChangedNick(oldNick,newNick) setTimer(check,1000,1,source) end addEventHandler("onPlayerChangeNick",getRootElement(),playerChangedNick) function playerQuit() removePlayerFromTeam(source) end addEventHandler("onPlayerQuit",getRootElement(),playerQuit) function loggedIn() check(source) end addEventHandler("onPlayerJoin",getRootElement(),loggedIn) function loggedOut() check(source) end addEventHandler("onPlayerLogout",getRootElement(),loggedOut) function initiate() local rootNode = getResourceConfig("config.xml") local children = xmlNodeGetChildren(rootNode) if children == false then return end for _,node in pairs(children) do local attributes = xmlNodeGetAttributes(node) local name = attributes.name local color = {getColorFromString(attributes.color)} if not color[1] then color = {255,255,255} end teams[name] = attributes teams[name].color = color if not toboolean(get("noEmptyTeams")) then teams[name].team = createTeam(name,unpack(color)) end end for k,v in pairs(getElementsByType("player")) do check(v) end end addEventHandler("onResourceStart",getResourceRootElement(),initiate) function check(player) if not isElement(player) or getElementType(player) ~= "player" then debug("No player") return end local nick = getPlayerName(player) local accountName = getAccountName(getPlayerAccount(player)) for name,data in pairs(teams) do local tagMatch = false local aclGroupMatch = false if data.tag ~= nil and string.find(nick,data.tag,1,true) then tagMatch = true end if data.aclGroup ~= nil and accountName and isObjectInACLGroup("user."..accountName,aclGetGroup(data.aclGroup)) then aclGroupMatch = true end if data.required == "both" then if tagMatch and aclGroupMatch then addPlayerToTeam(player,name) return end else if tagMatch or aclGroupMatch then addPlayerToTeam(player,name) return end end end removePlayerFromTeam(player) setPlayerTeam(player,nil) end function addPlayerToTeam(player,name) local team = teams[name].team if not isElement(team) or getElementType(team) ~= "team" then team = createTeam(teams[name].name,unpack(teams[name].color)) teams[name].team = team end setPlayerTeam(player,team) debug("Added player '"..getPlayerName(player).."' to team '"..name.."'") end function removePlayerFromTeam(player) setPlayerTeam(player,nil) debug("Removed player '"..getPlayerName(player).."' from team") if toboolean(get("noEmptyTeams")) then for k,v in pairs(teams) do local team = v.team if isElement(team) and getElementType(team) == "team" then if countPlayersInTeam(team) == 0 then destroyElement(team) end end end end end function toboolean(string) if string == "false" or not string then return false end return true end setElementData(getResourceRootElement(),"debug",true) function debug(string) if getElementData(getResourceRootElement(),"debug") then outputDebugString("autoteams: "..string) end end
  18. I got this already I mean , the player will be moved in the team but he doesnt spawn on the certein position
  19. it doesn´t work.. console says nothing. the point is, players will be moved if they LOGIN. that means the teams will be created if a player login. So i need something that players get their skills, skin ect. when they login.
  20. Don´t know whats wrong... Maybe someone have an idea what´s wrong.. addEventHandler("onResourceStart", resourceRoot, function() for i,player in ipairs(getElementsByType("player")) do spawn(player) end end ) function spawn(player) repeat until spawnPlayer ( player, 2824.647, -2438.673+math.random(-0,5), 14, 90, 0 ) fadeCamera(source, false, 0.1, 0, 0, 0 ) end addEventHandler("onPlayerLogin", root, function() spawn(source) local playerTeam = getPlayerTeam ( player ) if ( getTeamName(playerTeam) == "Mercenaries" ) then spawnPlayer ( player, 2800.721, -2455.929, 13.630, 90, 179, team ) giveWeapon(player, 4, 68) giveWeapon(player, 22, 68) giveWeapon(player, 31, 100) giveWeapon(player, 18, 5) setPlayerStat ( thePlayer, 69, 999 ) setPlayerStat ( thePlayer, 78, 1000 ) setPlayerStat ( thePlayer, 24, 1000 ) setPlayerStat ( thePlayer, 23, 1000 ) elseif ( getTeamName(playerTeam) == "Police" ) then spawnPlayer ( player, 1580.233, -1636.650, 13.553, 90, math.random(280,281) ) giveWeapon(player, 3, 1) giveWeapon(player, 22, 68) giveWeapon(player, 29, 120) setPlayerStat ( thePlayer, 69, 750 ) setPlayerStat ( thePlayer, 76, 1000 ) setPlayerStat ( thePlayer, 24, 1000 ) setPlayerStat ( thePlayer, 23, 1000 ) else spawnPlayer ( player, 2824.647, -2438.673+math.random(-0,5), 14, 90, 0 ) giveWeapon(player, math.random(2,7)) end end ) addEventHandler("onPlayerWasted", root, function() setTimer(spawn, 5000, 1, source) end )
  21. wow .. works...! Thanks a lot friend!
  22. hmm there must be a bug. this ressource doesn´t work but the console don´t say anything... the spawn script doesn´t, work the others does. i tried do debug but i don´t know... u use autoteams... if this is important there is the standart team ( civilian ) then ( police ) and ( mercenaries ) so this is what i did: addEventHandler("onResourceStart", resourceRoot, function() for i,player in ipairs(getElementsByType("player")) do spawn(player) end end ) function spawn(player) local playerTeam = getPlayerTeam ( player ) if ( getTeamName(playerTeam) == "Mercenaries" ) then spawnPlayer ( player, 2824.647+math.random(-0,5), -2438.673+math.random(-0,5), 13, 90, 179 ) giveWeapon(player, 22, 51) giveWeapon(player, 31, 100) setPlayerStat ( thePlayer, 69, 999 ) setPlayerStat ( thePlayer, 78, 1000 ) setPlayerStat ( thePlayer, 24, 1000 ) fadeCamera(player, true) setCameraTarget(player, player) elseif ( getTeamName(playerTeam) == "Police" ) then spawnPlayer ( player, 2300.647+math.random(-0,5), -2000.673+math.random(-0,5), 13, 90, 172 ) giveWeapon(player, 22, 51) setPlayerStat ( thePlayer, 70, 999 ) fadeCamera(player, true) setCameraTarget(player, player) else spawnPlayer ( player, 1000+math.random(-0,5), 1000+math.random(-0,5), 13, 90, 177 ) fadeCamera(player, true) setCameraTarget(player, player) end addEventHandler("onPlayerJoin", root, function() spawn(source) end ) addEventHandler("onPlayerWasted", root, function() setTimer(spawn, 5000, 1, source) end )
  23. simply change the coordinates in your ressource "play" then broph.lua thats all
×
×
  • Create New...