Jump to content

Castillo

Retired Staff
  • Posts

    21,935
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Castillo

  1. Castillo

    dxDrawColorText

    La funcion dxDrawText ahora soporta colores HEX, asi que no hace falta que uses una funcion propia ( dxDrawColorText ). Fijate en la wiki, hay un argumento para activarlos.
  2. I don't understand what are you trying to do.
  3. gResRoot = getResourceRootElement(getThisResource()) function loadAllHouses () local root = xmlLoadFile ("homes.xml") local houseroot = xmlFindChild (root,"houses",0) if (houseroot) then allHouses = {} for i,v in ipairs (xmlNodeGetChildren(houseroot)) do local x = xmlNodeGetAttribute (v,"x") local y = xmlNodeGetAttribute (v,"y") local z = xmlNodeGetAttribute (v,"z") local number = xmlNodeGetAttribute (v,"num") local pickupModel = ( xmlNodeGetAttribute ( v, "owner" ) == "" and 1273 or 1272 ) local pickup = createPickup ( tonumber ( x ), tonumber ( y ), tonumber ( z ), 3, pickupModel, 0 ) setElementData (pickup,"housenumber",tonumber(number)) outputDebugString ("House " .. tostring(number) .. " loaded!") end end end addEventHandler("onResourceStart",gResRoot, loadAllHouses) addEventHandler ("onPickupHit",getRootElement(), function(hitElement, dimension) if (getElementType (hitElement) == "player") and not (isPedInVehicle (hitElement)) then if (getElementData (source,"housenumber")) then local housenumber = getElementData (source,"housenumber") --outputChatBox (tostring(housenumber),hitElement,255,0,0,false) local root = xmlLoadFile ("homes.xml") local houseHeadRootNode = xmlFindChild (root,"houses",0) local houseRootNode = xmlFindChild (houseHeadRootNode,"house",tonumber(housenumber)) if (tostring(xmlNodeGetAttribute (houseRootNode,"owner")) == "") then triggerClientEvent (hitElement,"viewHouseGUIwindow",hitElement,"Nobody!",tostring(xmlNodeGetAttribute (houseRootNode,"cost")),housenumber) xmlUnloadFile (root) else triggerClientEvent (hitElement,"viewHouseGUIwindow",hitElement,tostring(xmlNodeGetAttribute (houseRootNode,"owner")),tostring(xmlNodeGetAttribute (houseRootNode,"cost")),housenumber) xmlUnloadFile (root) end end end end) addEvent("HouseSystemEnterHouse",true) addEvent("HouseSystemBuyHouse",true) addEvent("HouseSystemSellHouse",true) addEventHandler ("HouseSystemBuyHouse", getRootElement(), function(housenumber) local root = xmlLoadFile ("homes.xml") local houseHeadRootNode = xmlFindChild (root,"houses",0) local houseRootNode = xmlFindChild (houseHeadRootNode,"house",tonumber(housenumber)) local price = xmlNodeGetAttribute (houseRootNode,"cost") local owner = xmlNodeGetAttribute (houseRootNode,"owner") if not (isGuestAccount (getPlayerAccount(source))) then if (owner == "") and (getPlayerMoney (source) >= tonumber(price)) then takePlayerMoney (source,tonumber(price)) xmlNodeSetAttribute (houseRootNode,"owner",getAccountName(getPlayerAccount(source))) outputChatBox ("Congratulations, you are the new owner!",source,255,0,0,false) outputChatBox ("Price: ".. tostring(price) .. "$!",source,255,0,0,false) setPickupType ( getPickupByHousenumber(housenumber), 3, 1272 ) xmlSaveFile (root) elseif not (owner == "") then outputChatBox ("Sorry, This house is already bought!",source,255,0,0,false) elseif (getPlayerMoney (source) < tonumber(price)) then outputChatBox ("Sorry, you are too poor!",source,255,0,0,false) end else outputChatBox ("Please log in!",source,255,0,0,false) end triggerClientEvent (source,"hideHouseGuiWindow",source) xmlUnloadFile (root) end) addEventHandler ("HouseSystemSellHouse", getRootElement(), function(housenumber) local root = xmlLoadFile ("homes.xml") local houseHeadRootNode = xmlFindChild (root,"houses",0) local houseRootNode = xmlFindChild (houseHeadRootNode,"house",tonumber(housenumber)) local price = xmlNodeGetAttribute (houseRootNode,"cost") local owner = xmlNodeGetAttribute (houseRootNode,"owner") if not (isGuestAccount (getPlayerAccount(source))) then if (owner == getAccountName(getPlayerAccount(source))) then givePlayerMoney (source,tonumber(price)/2) xmlNodeSetAttribute (houseRootNode,"owner","") outputChatBox ("Congratulations, you have sold the home!",source,255,0,0,false) outputChatBox ("Obtain: ".. tostring(price)/2 .. "$!",source,255,0,0,false) setPickupType ( getPickupByHousenumber(housenumber), 3, 1273 ) xmlSaveFile (root) elseif not (owner == getAccountName(getPlayerAccount(source))) then outputChatBox ("This isn't your house!",source,255,0,0,false) end else outputChatBox ("Please log in!",source,255,0,0,false) end triggerClientEvent (source,"hideHouseGuiWindow",source) xmlUnloadFile (root) end) addEventHandler ("HouseSystemEnterHouse",getRootElement(), function(housenumber) local root = xmlLoadFile ("homes.xml") local houseHeadRootNode = xmlFindChild (root,"houses",0) local houseRootNode = xmlFindChild (houseHeadRootNode,"house",tonumber(housenumber)) local x,y,z = getElementPosition (source) if (xmlNodeGetAttribute (houseRootNode,"owner") == "") then setElementData (source,"posx",x) setElementData (source,"posy",y) setElementData (source,"posz",z) local interiornumber = xmlNodeGetAttribute (houseRootNode,"interior") local interiorRootNode = xmlFindChild (xmlFindChild (root,"interiors",0),"interior",tonumber(interiornumber)) setElementInterior (source,tonumber(xmlNodeGetAttribute (interiorRootNode,"id")),tonumber(xmlNodeGetAttribute (interiorRootNode,"x")),tonumber(xmlNodeGetAttribute (interiorRootNode,"y")),tonumber(xmlNodeGetAttribute (interiorRootNode,"z"))) setElementDimension (source,xmlNodeGetAttribute(houseRootNode,"dim")) outputChatBox ("Welcome! This house isn't bought yet!",source,0,255,0,false) outputChatBox ("To Exit This House, Type /exithouse",source,255,255,0,false) triggerClientEvent (source,"hideHouseGuiWindow",source) elseif (getAccountName(getPlayerAccount(source)) == xmlNodeGetAttribute (houseRootNode,"owner")) then setElementData (source,"posx",x) setElementData (source,"posy",y) setElementData (source,"posz",z) local interiornumber = xmlNodeGetAttribute (houseRootNode,"interior") local interiorRootNode = xmlFindChild (xmlFindChild (root,"interiors",0),"interior",tonumber(interiornumber)) setElementInterior (source,tonumber(xmlNodeGetAttribute (interiorRootNode,"id")),tonumber(xmlNodeGetAttribute (interiorRootNode,"x")),tonumber(xmlNodeGetAttribute (interiorRootNode,"y")),tonumber(xmlNodeGetAttribute (interiorRootNode,"z"))) setElementDimension (source,xmlNodeGetAttribute(houseRootNode,"dim")) outputChatBox ("Welcome!",source,0,255,0,false) outputChatBox ("To Exit Your House, Type /exithouse",source,255,255,0,false) triggerClientEvent (source,"hideHouseGuiWindow",source) elseif not (getAccountName(getPlayerAccount(source)) == xmlNodeGetAttribute (houseRootNode,"owner")) then outputChatBox ("You aren't the owner of this home!",source,255,0,0,false) outputChatBox ("If you are, make sure you are logged in!",source,255,0,0,false) end xmlUnloadFile (root) end) addCommandHandler ("exithouse", function(thePlayer,command) if (getElementInterior (thePlayer) ~= 0) and (getElementData (thePlayer,"posx")) and (getElementData (thePlayer,"posy")) and (getElementData (thePlayer,"posz")) then setElementPosition (thePlayer,getElementData (thePlayer,"posx"),getElementData (thePlayer,"posy"),getElementData (thePlayer,"posz")) setElementInterior (thePlayer,0) setElementDimension (thePlayer,0) removeElementData (thePlayer,"posx") removeElementData (thePlayer,"posy") removeElementData (thePlayer,"posz") end end) addCommandHandler ("createhouse", function(thePlayer,command,interiorid,dimension,price) if (interiorid) and (dimension) and (price) and (not isPedInVehicle(thePlayer)) then if (hasObjectPermissionTo (thePlayer,"command.aexec",false)) then local x,y,z = getElementPosition (thePlayer) local houseCount = tonumber(getHouseCount()) local root = xmlLoadFile ("homes.xml") local housesRoot = xmlFindChild (root,"houses",0) local newHouse = xmlCreateChild (housesRoot,"house") xmlNodeSetAttribute (newHouse,"num",houseCount) xmlNodeSetAttribute (newHouse,"interior",interiorid) xmlNodeSetAttribute (newHouse,"x",x) xmlNodeSetAttribute (newHouse,"y",y) xmlNodeSetAttribute (newHouse,"z",z) xmlNodeSetAttribute (newHouse,"cost",price) xmlNodeSetAttribute (newHouse,"owner","") xmlNodeSetAttribute (newHouse,"dim",dimension) outputChatBox ("The house will appear when you restart the resource!",thePlayer,255,0,0,false) xmlSaveFile (root) xmlUnloadFile (root) else outputChatBox ("Admin only!",thePlayer,255,0,0,false) end else outputChatBox ("Wrong syntax, or get out of your vehicle!",thePlayer,255,0,0,false) outputChatBox ("SYNTAX: /createhouse [interior ID] [Dimension] [price in $]",thePlayer,255,0,0,false) outputChatBox (" Interior ID - standard 0-21 - the standard houses.",thePlayer,255,0,0,false) outputChatBox (" Dimension - number between 0 and 65535, always take another each interior!",thePlayer,255,0,0,false) outputChatBox (" Price - How much does the home cost?",thePlayer,255,0,0,false) end end) function getHouseCount () local root = xmlLoadFile ("homes.xml") local housesRoot = xmlFindChild (root,"houses",0) local allHouses = xmlNodeGetChildren (housesRoot) houses = 0 for i,v in ipairs (allHouses) do houses = houses+1 end xmlUnloadFile (root) return houses end function getPickupByHousenumber (housenumber) for i,v in ipairs (getElementsByType("pickup")) do if (getElementData (v,"housenumber") == tonumber(housenumber)) then return v end end end Try it.
  4. Castillo

    Name

    Vas a tener que crear una tabla y guardar ahi.
  5. What you are saying is that with that script without all the other stuff to create it, it replaced it just fine?
  6. Do you get script errors? have you tried replacing another model?
  7. Castillo

    Name

    No le entendiste. addCommandHandler ( "Hola", function ( source, commandName, name ) Jugador1 = getPlayerName ( source ) Jugador2 = getPlayerFromNamePart ( name ) if ( Jugador2 ) then outputChatBox ( Jugador1 ..": ".. getPlayerName ( Jugador2 ), source ) end end ) function getPlayerFromNamePart(name) if name then for i, player in ipairs(getElementsByType("player")) do if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then return player end end end return false end
  8. Why do you get the vehicle again if you can use 'source' as vehicle?
  9. What executes "fuelUse" function?
  10. I did a simple test, created random vehicle get the plate text, and returns wrong one. I guess this function doesn't work so good.
  11. Try looping all vehicles and get their plate text.
  12. function getVehicleByPlate ( plate ) local found = false for _, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do if ( getVehiclePlateText ( vehicle ) == plate ) then found = vehicle break end end return found end
  13. Castillo

    Question

    Before playing the sound you can check if they bought them.
  14. Yo movi el tema de la seccion ingles.
  15. We don't help these who use illegal scripts. Topic locked.
  16. Castillo

    Question

    You want to move the chat box? if so, that's not possible.
  17. addEventHandler ( "onPlayerSpawn", root, function ( ) setElementAlpha ( source, 0 ) setTimer ( setElementAlpha, 5000, 1, source, 255 ) end )
×
×
  • Create New...