Jump to content

Gordon_G

Members
  • Posts

    282
  • Joined

  • Last visited

Everything posted by Gordon_G

  1. For this you need to undestand the MTA DayZ Gamemode : The contains of inventorys and tents are defined by elementData. You'll have to use these functions : setElementData() getElementData()
  2. Hum... Put it in a table.. I don't really understand what you're trying to do.
  3. The dbExec returns a table so, if you want to make something like this you should use : dbExec() -- Like in your code dbPoll() -- Because you need the result of your dbExec And you could use the '#' to count the number of lines into the returned result of your dbPoll If you've any other question, ask here.
  4. Gordon_G

    Teams Tag

    Damn it. Hum... You will need these function : getPlayerTeam() -- Get the player's team when he disconnect getTeamName() -- Because getPlayerTeam() returns a userdata value but we need a string setAccountData() -- Save the player's team on quit getAccountData() -- Get player team when he disconnected getTeamFromName() -- Because our account data is a string, not a userdata setPlayerTeam() -- Set player team when he joins getPlayerName() -- Take the player name setPlayerName() -- Add to the name the team name Ask if you have any other question. EDIT : Loki, you're too fast for me x'(
  5. Hello ! I'm trying to do a script, and I need to turn the player, to a point. I know it will be a mathematical function, I started like this but it's not working : function turn(source) local x,y,z = getElementPosition(source) local x1,y1,z1 = -2004.1025390625,146.181640625,27.5390625 local Player_A = getDistanceBetweenPoints2D(x,y,0,0) local A_point = getDistanceBetweenPoints2D(0,0,x1,y1) print(A_point) print(Player_A) local rot = math.deg(math.atan(Player_A/A_point)) print(rot) setElementRotation(source,0,0,rot) end addCommandHandler("turn",turn) Could someone help me ? Thanks !
  6. Hello, I would like to get the last updates by an xml file and write it in a memo. But ; for this I need to pass lines. My xml : <settings> <news>something \n other</news> </settings> server : -- Server : function showNews(source) local settings = xmlLoadFile(":script/settings.xml") triggerClientEvent(source,"shownews",source,xmlNodeGetValue(xmlFindChild(settings, "news", 0))) end -- I made a bind a bind to this function somewhere else in my script and it work so, it's not the problem client : -- Client : function showNews(news_) if news then destroyElement(news) else local screenW, screenH = guiGetScreenSize() news = guiCreateMemo((screenW - 505) / 2, (screenH - 304) / 2, 505, 304, news_, false) end end addEvent("shownews",true) addEventHandler("shownews",getLocalPlayer(),showNews) So, when I push my key who is bind, I can see the memo, I can see the text but, I would like to see it like this : "something other" not like this "something \n" Thanks !
  7. Oh, thanks. I didn't noticed it in the wiki
  8. Hello, I know how to freez an element, I know how to freez an element but I would like something like this : When my ped is hit (by a punch for exemple) he still in his animation. Is it possible ? Thanks !
  9. I took my motivation and I did something like this to make easily colRectangle : col_rect = {} function colrect(source) x,y,z = getElementPosition(source) if col_rect.un == nil then table_ = {x,y} col_rect.un = table_ outputChatBox("1") elseif col_rect.deux == nil then table_ = {x,y} outputChatBox("2") col_rect.deux = table_ elseif col_rect.trois == nil then table_ = {x,y} outputChatBox("3") col_rect.trois = table_ local a = getDistanceBetweenPoints2D(col_rect.un[1],col_rect.un[2],col_rect.trois[1],col_rect.trois[2]) local b = getDistanceBetweenPoints2D(col_rect.un[1],col_rect.un[2],col_rect.deux[1],col_rect.deux[2]) local x,y = col_rect.un[1],col_rect.un[2] local w = a local h = math.sqrt(a^2-b^2) rect__ = createColRectangle(x,y,w,h) print(x..","..y..","..w..","..h) col_rect = {} end end addCommandHandler("rect",colrect) Thanks to everyone.
  10. Hello, I know the event "onRadarAreaElementEnter" do not exist but, I would like to have something like this. In my script I've some radar area but I cant use any colshape (because I've some negatives lenghts) or zone because my areas are not the same than the zone. Could someone find a way to have an event like "onRadarAreaElementEnter" ? Thanks a lot !
  11. Hello, in LUA the return is like end or break when you use for. So, remove the end after the return false.
  12. medicsTeam = createTeam("Axis",255,0,0) He's right. You should try with this first.
  13. Mhh ... You asked something I gave you a big part of you script. We'll (by "we" I say the MTA's forum) not script your gamemode for you. You must be sure of that. And for my little error, yes. Replace the line 30 by this : setVehicleLocked(v, locked)
  14. I'm sorry but this is not correct. So, let's do something like this : -- First : Make this function in your script, she's realy usefull function table.contains(table, element) for _, value in pairs(table) do if value == element then return true end end return false end -- Ok now we'll define all the LSPD vehicles : lspdv = {596, 598, 427, 601, 599, 528, 490} -- You can add or remove some value(s) by this table. function lock (source) if not isPedInVehicle(source) then local x,y,z = getElementPosition(source) local colshape = createColShape(x,y,z,2) -- Ok, here the colshape is not too big but it's for don't have any bug local elements = getElementsWithinColShape(colshape, "vehicle") destroyElement(colshape) if #elements == 1 then -- So here the # is to count the number of vehicle in the colshape for _,v in ipairs(elements) do local model = getElementModel(v) if table.contains (lspdv, model) then -- We check if the vehicle near the player is the lspdv table -- Ok, here make you faction detection with "if" and after don't forget to make an end local locked = isVehicleLocked ( vh ) local locked = not locked setVehicleLocked(vh, locked) end end else outputChatBox("Sorry, too much vehicles / any vehicle near you.", source, 255,0,0) end else local vh = getPedOccupiedVehicle(source) local model = getElementModel(source) if table.contains(lspdv, model) then -- Ok, here make you faction detection with "if" and after don't forget to make an end local locked = isVehicleLocked ( vh ) local locked = not locked setVehicleLocked(vh, locked) end end end addCommandHandler("lock",lock) Ok, so now, make that for the engine. We'll see if you have learn something. And ... You can join me by private message, I could help you ...
  15. How does this even work? There is no event handling the function. Oh, f*ck I'm so stupid ... Write that after the last "end" ... addEventHandler( "onMarkerHit", getRootElement(), MarkerHit )
  16. function MarkerHit( hitElement) if getElementType(hitElement) == "player" then -- getElementType because theElement must be a player local r,g,b = getMarkerColor(source) if r == 255 and g == 0 and b == 0 then -- We check the color of the marker local x,y,z = getElementPosition(hitElement) -- Get the position of the player if not isPedInVehicle(hitElement) then -- Check if the player is already in vehicle local vehicle = createVehicle(vehiclesid[math.random(1,#vehiclesid)],x,y,z,0,0,getPedRotation(hitElement)) -- The math.random will take an aleatory number in the table 'vehiclesid'. The # count the lines in a table so, like this you can add some other IDs in your table warpPedIntoVehicle(hitElement, vehicle) -- Warp the player into the vehicle end end end end I retry this this moon and, it work perfectly
  17. function MarkerHit( hitElement) if getElementType(hitElement) == "player" then -- getElementType because theElement must be a player local r,g,b = getMarkerColor(source) if r == 255 and g == 0 and b == 0 then -- We check the color of the marker local x,y,z = getElementPosition(hitElement) -- Get the position of the player if not isPedInVehicle(hitElement) then -- Check if the player is already in vehicle local vehicle = createVehicle(vehiclesid[math.random(1,#vehiclesid)],x,y,z,0,0,getPedRotation(hitElement)) -- The math.random will take an aleatory number in the table 'vehiclesid'. The # count the lines in a table so, like this you can add some other IDs in your table warpPedIntoVehicle(hitElement, vehicle) -- Warp the player into the vehicle end end end end This code work. I just edit a little bit.
  18. Humpf ... The createBlip or createBlipAttachedTo already got the "visibleto" createBlipAttachedTo ( element elementToAttachTo [, int icon = 0, int size = 2, int r = 255, int g = 0, int b = 0, int a = 255, int ordering = 0, float visibleDistance = 99999.0, visibleTo = getRootElement( ) ] ) Try something like this : createBlipAttachedTo(v,22,2,255,0,0,255,0,99999.0,v) Instead of local blip = createBlipAttachedTo(v,22) for i,v in pairs(getElementsByType("player")) do local playerTeam = getTeamName(getPlayerTeam(v)) if playerTeam == "Axis" then setElementVisibleTo(blip,v,true) else setElementVisibleTo(blip,v,false) end end
  19. So ... I can't help you on this script ... It's ... Really hard ... You gave me all the gamemode ... I just want the bugged script Is it your script ?
  20. Yes, it's possible ! -- Server function onElementModelChange () if getElementModel(source) == 45 then giveWeapon(source,42,10000000, true) end end addEventHandler("onElementModelChange", root,onElementModelChange) Something like that ...
  21. vehiclesid = {429, 541, 480 , 411 , 565} changermarker = createMarker(x, y, z, "typeofmarker", size,255, 0, 0, alpha) function MarkerHit( hitElement) if getElementType(hitElement) == "player" then -- getElementType because theElement must be a player if getMarkerColor(source) == 255,0,0 then -- We check the color of the marker local x,y,z = getElementPosition(hitElement) -- Get the position of the player createVehicle(vehiclesid[math.random(1,#vehiclesid)],x,y,z,0,0,getPedRotation(hitElement)) -- The math.random will take an aleatory number in the table 'vehiclesid'. The # count the lines in a table so, like this you can add some other IDs in your table end end end addEventHandler( "onMarkerHit", getRootElement() , MarkerHit) I don't try this but it should work
  22. I don't really understand what do you want to do but ... "menu of RESPAWN", so, a GUI ? If it's that, do you make de cursor visible ? showCursor(true,true) Please, insert your code.
  23. Ok, I will try that when my friend will be here, thanks !
×
×
  • Create New...