Jump to content

Aron800

Members
  • Posts

    18
  • Joined

  • Last visited

Everything posted by Aron800

  1. Hello, I want to make a script that if you join and you are in a xml list as a member of the gang. That you will join the team. But i got a problem. It is not returning any errors. This is my script: teams.lua: gResRoot = getResourceRootElement(getThisResource()) function loadGangs () local root = xmlLoadFile("gangs.xml") if (gangRoot) then for i,gang in ipairs (xmlNodeGetChildren(root)) do local info = xmlFindChild(gang, "info", 0) if info then local colorR = xmlNodeGetAttribute(gang, "colorR") local colorG = xmlNodeGetAttribute(gang, "colorG") local colorB = xmlNodeGetAttribute(gang, "colorB") local name = xmlNodeGetAttribute(gang, "gangName") createTeam(gangName, colorR, colorG, colorB) end end end end addEventHandler("onResourceStart",gResRoot, loadGangs) function onLogin () local root = xmlLoadFile("gangs.xml") local play = getPlayerAccount(source) local player = getAccountName(play) for i,gang in ipairs (xmlNodeGetChildren(root)) do local member = xmlNodeGetAttribute(gang, "name") local gangName = xmlNodeGetAttribute(gang, "gangName") if (member == player) then local theTeam = getTeamFromName(gangName) setPlayerTeam(source, theTeam) end end xmlUnloadFile(root) end addEventHandler ("onPlayerLogin", getRootElement(), onLogin) gangs.xml: <gangs> <Grove Street> <info gangName="Grove Street" colorR="0" colorG="255" colorB="0" /> <member name="Aron" rank="3" /> </Grove Street> </gangs> So what do i need to do?
  2. It works thanks again
  3. Yes cars.xml is the same And it returns false But my map looks like this: * cars.xml * meta.xml * help.xml * spawn.lua * playerMenu.lua
  4. Again another problem: I made a script, you can lock and unlock your car but you can only have one car now. So i want to make a player menu. And in the player menu you need to select your car. But when i try it it returns an error. My script: function startWindow(thePlayer) local X = 0.375 local Y = 0.375 local Width = 600 local Height = 330 playerMenu = guiCreateWindow(X, Y, Width, Height, "Player Menu (M)", false) tabWidget = guiCreateTabPanel(10, 25, 581, 291, false, playerMenu) tabCars = guiCreateTab("Cars", tabWidget) listWidget = guiCreateGridList(12, 30, 551, 192, false, tabCars) guiGridListSetSortingEnabled(listWidget, false) listWidget_col = guiGridListAddColumn(listWidget, "Your cars:", 0.85) local listWidget_row = nil label = guiCreateLabel(220, 10, 151, 16, "Select a car and press Ok", false, tabCars) guiLabelSetHorizontalAlign(label, "left", false) guiLabelSetVerticalAlign(label, "center") btnOk = guiCreateButton(390, 230, 75, 23, "Ok", false, tabCars) btnCancel = guiCreateButton(470, 230, 75, 23, "Cancel", false, tabCars) tabTaxi = guiCreateTab("Taxi", tabWidget) local root = xmlLoadFile ("cars.xml") local carRoot = xmlFindChild (root,"parked",0) for i,v in ipairs (xmlNodeGetChildren(carRoot)) do local carOwner = xmlNodeGetAttribute(v, "owner") local num = xmlNodeGetAttribute(v, "num") local carName = "car" .. xmlNodeGetAttribute(v, "num") if (carOwner == thePlayer) then listWidget_row = guiGridListAddRow(listWidget) guiGridListSetItemText(listWidget, listWidget_row, listWidget_col, carName, false, false ) end end xmlUnloadFile (root) guiSetVisible (gui, true) showCursor(true) end addEvent( "startWindow", true ) addEventHandler( "startWindow", getRootElement(), startWindow ) And my server.lua: function PlayerJoin ( ) bindKey ( source, "m", "down", playerMenu ) end addEventHandler ( "onPlayerJoin", getRootElement(), PlayerJoin ) function playerMenu(thePlayer) local play = getPlayerAccount(thePlayer) local player = getAccountName(play) triggerClientEvent ( "startWindow", getRootElement(), player) end local carRoot = xmlFindChild (root,"parked",0) -- This line retruns: Bad argument @ 'xmlFindChild' for i,v in ipairs (xmlNodeGetChildren(carRoot)) do -- This line returns: Bad argument @ 'xmlNodeGetChildren' And i cant find out what is wrong because this works server side and it says on the wiki server and client side.
  5. And is there a way to update the x,y,z and rotation of the car if you do the /park command? EDIT: Maybe if i setElementData to the number of the car?
  6. Thank you it works. And how can i find out if you are the car owner or not if you are in the car?
  7. The rotation of the car. But my last question i think: gResRoot = getResourceRootElement(getThisResource()) function loadCars () local root = xmlLoadFile ("cars.xml") local carRoot = xmlFindChild (root,"parked",0) if (carRoot) then allCars = {} for i,v in ipairs (xmlNodeGetChildren(carRoot)) do local carmodel = xmlNodeGetAttribute(v, "model") local carX = xmlNodeGetAttribute(v, "posX") local carY = xmlNodeGetAttribute(v, "posY") local carZ = xmlNodeGetAttribute(v, "posZ") local carA = xmlNodeGetAttribute(v, "rot") local carName = "car" .. xmlNodeGetAttribute(v, "num") local car = createVehicle(carmodel, carX, carY, carZ, 0.0, 0.0, carA) setElementID(car, carName) end end end addEventHandler("onResourceStart",gResRoot, loadCars) addCommandHandler ("park", function(thePlayer,command) local theVehicle = getPedOccupiedVehicle (thePlayer) local root = xmlLoadFile ("cars.xml") local carRoot = xmlFindChild (root,"parked",0) local carNumber = getElementID(theVehicle) outputChatBox ("Het is: " .. carNumber,thePlayer,255,0,0,false) if (carNumber == "") then if (getPedOccupiedVehicleSeat (thePlayer) == 0) then local x,y,z = getElementPosition (theVehicle) local carModel = getElementModel (theVehicle) local carRot = getVehicleRotation (theVehicle) local carCount = tonumber(getCarCount()) local newCar = xmlCreateChild (carRoot,"car") xmlNodeSetAttribute (newCar,"num",carCount) xmlNodeSetAttribute (newCar,"model",carModel) xmlNodeSetAttribute (newCar,"posX",x) xmlNodeSetAttribute (newCar,"posY",y) xmlNodeSetAttribute (newCar,"posZ",z) xmlNodeSetAttribute (newCar,"rot",carRot) xmlNodeSetAttribute (newCar,"owner",thePlayer) local carName = "car" .. carCount setElementID(theVehicle, carName) outputChatBox ("Your car is parked!",thePlayer,255,0,0,false) xmlSaveFile (root) xmlUnloadFile (root) else outputChatBox("You must be the driver of a car to do this!",thePlayer,255,0,0,false) end else if (getPedOccupiedVehicleSeat (thePlayer) == 0) then outputChatBox ("Je auto is al geparkeerd!",thePlayer,255,0,0,false) else outputChatBox ("You must be the driver of a car to do this!",thePlayer,255,0,0,false) end end end) function getCarCount () local root = xmlLoadFile ("cars.xml") local carRoot = xmlFindChild (root,"parked",0) local allCars = xmlNodeGetChildren (carRoot) cars = 0 for i,v in ipairs (allCars) do cars = cars+1 end xmlUnloadFile (root) return cars end But this is not working: xmlNodeSetAttribute (newCar,"owner",thePlayer) -- it returns [2010-08-03 11:29:56] WARNING: car_respawn\server.lua:48: Bad argument @ 'xmlNodeSetAttribute' And how can i find out who the owner is?
  8. Thanks it works. And one other question: If i want to give the car a name and an ID how do i give it the name car0 and car1? Because this doesn't work: local carName = "car" + xmlNodeGetAttribute(v, "num") carName=createVehicle(carmodel, carX, carY, carZ, 0.0, 0.0, carA) setElementID(carName,carName)
  9. I am not really sure but you can just use [lua][/lua]
  10. Hello, I started with scripting 2 weeks ago and i want to try something but it doesn't work. My script.lua: gResRoot = getResourceRootElement(getThisResource()) function loadCars () local root = xmlLoadFile ("cars.xml") local carRoot = xmlFindChild (root,"parked",0) if (carRoot) then allCars = {} for i,v in ipairs (xmlNodeGetChildren(carRoot)) do local carmodel = xmlNodeGetAttribute(carRoot, "model") local carX = xmlNodeGetAttribute(carRoot, "posX") local carY = xmlNodeGetAttribute(carRoot, "posY") local carZ = xmlNodeGetAttribute(carRoot, "posZ") local carA = xmlNodeGetAttribute(carRoot, "rot") createVehicle(carmodel, carX, carY, carZ, 0.0, 0.0, carA) end end end addEventHandler("onResourceStart",gResRoot, loadCars) It needs to spawn some vehicles that are in my cars.xml: <cars> <parked> <car num="0" model="411" posX="0" posY="-30" posZ="3" rot="90.0" /> <car num="1" model="432" posX="-30" posY="0" posZ="3" rot="90.0" /> parked> cars> But it returns: WARNING: car_spawn\server.lua:14: Bad argument @ 'createVehicle' So what is wrong with it?
  11. Does anyone know how i can let it work?
  12. I know but if i let engineer accelerate then the train needs to be moving. But that doesn't work...
  13. It still doesn't work but i found what is wrong setPedControlState(engineer,"accelerate",true) When i try to run the code with runcode it returns: Aron executed command: setPedControlState(engineer,"accelerate",true) Error: [string "return setPedControlState(engineer,"acceler..."]:1: attempt to call global 'setPedControlState' (a nil value) But i dont know how i can make this work. That setPedControlState works if i make a pilot so maybe it does not work on a train?
  14. Im not getting an error and that is a good idea but how can i make it work?
  15. Well being a passenger i will add later but how can i declare the engineer on the client-side script and make it work?
  16. Hello, I want to make a train in my server but it doesn't work.. My code in: train_server.lua engineer=createPed(227,1479,2669,3) train=createVehicle(537,1479,2669,3) setTrainDerailable(train, false) warpPedIntoVehicle(engineer,train) triggerClientEvent ( "driveTrain", getRootElement()) My code in: train_client.lua function driveTrain() Engineer=getVehicleOccupant(getPedOccupiedVehicle(getLocalPlayer())) setPedControlState(Engineer,"accelerate",true) end addEvent( "driveTrain", true ) addEventHandler( "driveTrain", getRootElement(), driveTrain ) The Ped will come in the train with this script but the train doesn't go. So does anyone know what's wrong with this script Aron
×
×
  • Create New...