Jump to content

Citizen

Moderators
  • Posts

    1,803
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by Citizen

  1. No don't listen to him ! His script is as bugged as your original script. Please read and try to understand my comments (both of you). My comments are mainly to make you understand how element datas work for a 1st approach: taxiVehicles = { [420]=true, [438]=true } function enterVehicle ( thePlayer, seat, jacked ) if taxiVehicles[getElementModel( source )] and seat == 0 then -- if seat == 0, then it's the driver seat -- do not use globals for that local taxiBlip = createBlipAttachedTo(source, 0, 3, 255, 255, 0, 255, 0, 999999) setElementData(source, "attachedBlip", taxiBlip) -- Hey vehicle (source) ! I give you something to remember for me, its key is "attachedBlip". Thanks -- so I do not need to store it in a table or something end end addEventHandler ( "onVehicleEnter", root, enterVehicle ) function exitVehicle ( thePlayer, seat, jacked ) if taxiVehicles[getElementModel( source )] then local taxiBlip = getElementData(source, "attachedBlip") -- Hey vehicle (source) ! give me the thing you had to remember for me with the key "attachedBlip". Thanks (and I store his response in taxiBlip local variable so I can use it) if taxiBlip and isElement(taxiBlip) then -- to be sure the thing he gave us is not null or false and is an element destroyElement(taxiBlip) --destroy it end end end addEventHandler ( "onVehicleExit", root, exitVehicle ) A unique variable can hold only one value at a time ! (can be a number, string or mta elements like markers, blips, vehicles, players etc). So imagine, if one guy enter in a taxi, it will create a blip that you are storing into the taxiBlip variable. And while that first guy is still driving it, another player enters in another taxi. It will create another blip, ok, but you will store that other blip in the exact same taxiBlip variable. So now taxiBlip holds the reference to the new created blip. Hmmm yeah and what happened to the first blip's reference ? - It has been thrown away, so you cannot access to that blip anymore (it hasn't been destroyed, so it's still visible on the map). And when the first driver exits his taxi, you are destroying the element stored in taxiBlip variable. But if you are still understanding right, this variable holds the reference to the second blip created. So you are basically destroying the blip of the second player instead of the first one. We can use lua tables to hold every blips created on the taxis and using the vehicle as a key (for a key-value table). But it's a way simpler to use element datas as I shown you. It uses tables internally, so you don't have to mess with those things. Hope it's more clear now. (the blip wasn't created because you used taxiVehicles in createBlipAttachedTo instead of source, which is the vehicle)
  2. Then override the starting rotation of that projectile by specifying the optional arguments:
  3. It's => "How can I ..." (please remember it) By learning how to code ! You server is 80% made by others, so please learn ! And what would be a better way to learn than reading a working scripts with comments: local objeto5 = createObject ( 6959, -2038.5999755859, -81.400001525879, 90, 0, 90, 90 ) local objeto6 = createObject ( 6959, -2074.8999023438, -81.400001525879, 90, 0, 90, 90 ) local state1 = false local moving1 = false --We will use it to know if the gate is moving or not function Funcion ( thePlayer ) -- Please rename that function ! if moving1 then return end --If the gate is moving, cancel the function immediatly local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "|FEDG|" ) ) then if not state1 and then state1 = true moving1 = true -- the gate is moving setTimer(function () moving1 = false end, 2000, 1) -- gate is not moving after 2000ms moveObject ( objeto5, 2000, -2038.5999755859, -81.400001525879, 110, 0, 0, 0) moveObject ( objeto6, 2000, -2074.8999023438, -81.400001525879, 110, 0, 0, 0) outputChatBox ( "#0000ff[base FEDG] => #ffffffAbriendo #00ff00Aereo", thePlayer, 255, 255, 255, true ) else state1 = false moving1 = true -- the gate is moving setTimer(function () moving1 = false end, 2000, 1) -- gate is not moving after 2000ms moveObject ( objeto5, 2000, -2038.5999755859, -81.400001525879, 90, 0, 0, 0) moveObject ( objeto6, 2000, -2074.8999023438, -81.400001525879, 90, 0, 0, 0) outputChatBox ( "#0000ff[base FEDG] => #ffffffCerrando #ff0000Aereo", thePlayer, 255, 255, 255, true ) end else outputChatBox ( "No perteneces al clan FEDG", thePlayer, 255, 0, 0, true ) end end addCommandHandler ( "fedgaereo", Funcion ) -- If you renamed the function, change it here too
  4. It's obviously to make it work with a zombie gamemode that has created this event. @AbaZa: Try to add this line (above the addEventHandler of that event): addEvent( "onZombieWasted", true)
  5. Citizen

    reg

    I already told you what to do (twice) so please learn to read.
  6. Citizen

    reg

    No seriously, close the server, open acl.xml, and put this in the Admin group: <object name="resource.bplogin"></object> Do the same with admin instead of bplogin. Please learn from our replies instead of copying pasting without understanding. And if you can't, then read this: Access Control List
  7. Citizen

    Tables

    You are using the same function to update the client-side resource table to update your gui using onClientGUIClick which doesn't send the table as argument at all. So you were basicaly replacing the table by the button ("left", "middle" or "right"), when you were clicking on your gridlist. So please don't mix functions that don't take the same arguments or that doesn't do the same task. Also stop renaming your functions and tables with weird names. And finally reduce the ammount of triggers to save bandwidth. To do that, use only one table that you will send on the client-side. The table on the client-side part must be global (like RSresourcesinfo is) so you can use that table whereever you would like on the client-side. I let you update the server part to remove resources and use resourcesinfo only. client: RSresourcesinfo = {} function updateResourceInfos(resources) RSresourcesinfo = resources end addEvent("RSgetinfo", true) addEventHandler("RSgetinfo", root, RSgetinfo) function RSGridlistClicked( button, state ) if button ~= "left" and state ~= "up" then return end if guiGridListGetSelectedItem (RS_gridlist) ~= -1 then local RSinfores = guiGridListGetItemText ( RS_gridlist, guiGridListGetSelectedItem ( RS_gridlist ), Rsnamecol ) guiSetText(RSIauthor_lab, "Author: "..RSresourcesinfo[RSinfores].author) -- > That's the line which has the error --guiSetText(RSIfullname_lab, "Full name: "..fullnameRS.."") --guiSetText(RSIversion_lab, "Version: "..versionRS.."") end end addEventHandler( "onClientGUIClick", RS_gridlist, RSGridlistClicked) Don't forget to call GLresRS when you need to update the table on the client-side part. Note: if that doesn't work, it's basically that RSinfores isn't a valid resource name.
  8. Citizen

    XML Data

    Myeah just spotted that I wrote rootNote instead of rootNode at some places. I said it was working because the outputs were good. But the xmlSaveFile couldn't work (that's why it was never saved in the folder): function playersData() local fileName = "Data.xml" local rootNode = xmlLoadFile(fileName) --to load it once if not rootNode then rootNode = xmlCreateFile(fileName, "Data") if rootNode then outputChatBox("File created !", source) else outputChatBox("Failed to create the file !", source) return end end local playerName = getPlayerName(source) local playerLevel = getElementData(source, "LV") or 0 local playerNode = xmlCreateChild(rootNode, "Player") xmlNodeSetAttribute(playerNode, "Name", playerName) xmlNodeSetAttribute(playerNode, "Level", playerLevel) xmlSaveFile(rootNode) xmlUnloadFile(rootNode) outputChatBox("Succesfully saved !", source) end addEventHandler("onPlayerLogin", root, playersData) Should be the last time I update this script.
  9. Code should be this: local number = 5.123456 number = tonumber(string.sub(tostring(number), 1, number < 0 and 5 or 4)) outputChatBox(...) -- 5.123456 outputs 5.12 outputChatBox(...) -- -5.123456 outputs -5.12 Totally right, I didn't think about it.
  10. Citizen

    XML Data

    Here is my code again with the fix of the mistake I made (thanks Solidsnake) and now storing that file in your resource folder: function playersData() local fileName = "Data.xml" local rootNote = xmlLoadFile(fileName) --to load it once if not rootNode then rootNode = xmlCreateFile(fileName, "Data") outputChatBox("File created !", source) end local playerName = getPlayerName(source) local playerLevel = getElementData(source, "LV") or 0 local playerNode = xmlCreateChild(rootNode, "Player") xmlNodeSetAttribute(playerNode, "Name", playerName) xmlNodeSetAttribute(playerNode, "Level", playerLevel) xmlSaveFile(rootNote) xmlUnloadFile(rootNode) --don't forget to unload it outputChatBox("Succesfully saved !", source) end addEventHandler("onPlayerLogin", root, playersData) By the way, the code should have work once properly. The fact that it didn't work for you let me think you have an error in the same file. Please check the errors in the console when you start that resource. (Note this is a server side script) And as I said, I tested it and it worked !
  11. Citizen

    XML Data

    Data must be a valid resource's name. I tried with: xmlLoadFile("Data.xml") And it worked perfectly. If you wanted to put it in the Data folder that is in the same resource that this code, then use this: xmlLoadFile("Data/Data.xml")
  12. Citizen

    Tables

    Seems like we can't because the elements aren't the same on the server and the client (which was pretty obvious but idk why I thought it would work). Basically the pointers aren't the same at all so we can't use the element as key for the index. To make it work, I had to use the name of the resource instead: function resources() local resources = {} for k, resource in ipairs(getResources()) do if getResourceInfo(resource, "type") ~= "map" then resources[getResourceName(resource)] = {state=getResourceState(resource)} end end end (I removed name from the datas because we don't need it twice. If you want to add the author, do it in the brackets where state is). So on the client side, just use the resource name instead of the resource element: resources["admin"].state --> "running"
  13. Citizen

    Tables

    and how do you call that function (RSgetinfo) ?
  14. Citizen

    reg

    Use /register password password (it's a built-in command) then close the server, open the acl.xml and add this in the Admin group: <object name="user.YourNickname"></object> Restart the server, connect into it and use /login password. You will see in the chat that you can press 'P' to open the admin panel. So just press that key.
  15. Citizen

    XML Data

    Nope, but this one does: function playersData() local rootNote = xmlLoadFile(":Data/Data.xml") --to load it once if not rootNode then rootNode = xmlCreateFile("Data.xml", "Data") outputChatBox("File created !", source) end local playerName = getPlayerName(source) local playerLevel = getElementData(source, "LV") or 0 local playerNode = xmlCreateChild(rootNode, "Player") xmlNodeSetAttribute(playerNode, "Name", playerName) xmlNodeSetAttribute(playerNode, "Level", playerLevel) xmlSaveFile(rootNote) xmlUnloadFile(rootNode) --don't forget to unload it outputChatBox("Succesfully saved !", source) end addEventHandler("onPlayerLogin", root, playersData) <Data> <Player Name="Nikolai", Level="3"></Player> <Player Name="Citizen", Level="1"></Player> </Data> (It will be easier for you to use the attributes instead of the value of the node)
  16. Did he post the function that loads the vehicles ?! So was this correct ?! local ownerName = getElementData(theVehicle, "owner") or "null"
  17. No it won't work with xmlNodeGetName but with xmlNodeGetAttribute instead. But you first need to open the file, find the vehicle node that has the same id (using xmlNodeGetAttribute) then use xmlNodeGetAttribute again to get the owner name, then unload the xml file. It a pure waste of processor time because I'm sure at 99% that this owner data is already stored somewhere on the vehicle element (surely an element data). Let's see who is right
  18. And in the "manual" way: 1 - turn it into a string 2 - take the 4 first caracters of it (in "5,12" there are 4 caracters) 3 - turn the result back into a number local number = 5.123456 number = tonumber(string.sub(tostring(number), 1, 4)) outputChatBox(number) --outputs 5.12
  19. Citizen

    idiot question

    change the values in the tocolor() function: tocolor(red, green, blue, alpha) Example: tocolor(255, 0, 0, 255) Will draw your circle in full red (so no green and no blue in that color).
  20. Are you using a resource to save the vehicles in that xml ? If yes then give the link of that resource to us. Because we need to see where the owner is stored on the element when this resource loads the vehicles. If it's a script that someone made for you, please paste the loading function (that loads and create the cars from the xml). I'm pretty sure the owner is stored as an element data so you maybe can try to get it like this: local ownerName = getElementData(theVehicle, "owner") or "null" And hmmm about your comment on this line: local owner = getElementID(theVehicle) -- only give the id : ( Of course ! getElementID returns the id of the element ... Why would you get the owner with that function too ?! Seriously ... EDIT: @Max+, your are going the wrong way, this pretty obvious that he is using a script he got somewhere to save and load the vehicles into and from an xml file that he pasted a piece of in his first post. So I'm pretty sure that this script is setting the owner name as an element data of that vehicle at load time. So there is no need to read the xml file again.
  21. Citizen

    Tables

    Myeah lol my bad: local resser = nil local resname = "admin" for k, res in ipairs (resources) do if res.name == resname then resser = res.state end end if resser ~= nil then outputChatBox(resser) else outputChatBox("Resource "..resname.." not found in the table.") end Because we filled the table using table.insert and this functions make this table to use the number of the row as index. If you want to use the resource element as index, we had to fill our table this way: function resources() local resources = {} for k, resource in ipairs(getResources()) do if getResourceInfo(resource, "type") ~= "map" then resources[resource] = {name=getResourceName(resource), state=getResourceState(resource)}) end triggerClientEvent("ResourcesTable", root, resources) end end Like this I explecitly use the resource element as index. So now I can use this table like I wrote you in my previous post: local resource = getResourceFromName ( "admin" ) local state = resources[resource].state outputChatBox(state) Sorry for the mistake
  22. Citizen

    reg

    Lol thanks to Cpt. Obvious. No seriously, close the server, open acl.xml, and put this in the Admin group: <object name="resource.bplogin"></object>
  23. Citizen

    XML Data

    function playersData() local rootNote = xmlLoadFile(":Data/Data.xml") --to load it once if not rootNode then rootNode = xmlCreateFile("Data.xml", "Data") xmlCreateChild(rootNode, "Player") xmlSaveFile(rootNode) outputChatBox("File created !", source) end local playerNode = xmlFindChild(rootNote, "Player", 0) local playerName = getPlayerName(source) local playerLevel = getElementData(source, "LV") or 0 xmlNodeSetAttribute(playerNode, "Name", playerName) xmlNodeSetAttribute(playerNode, "Level", playerLevel) xmlUnloadFile(rootNode) --don't forget to unload it outputChatBox("Succesfully saved !", source) end addEventHandler("onPlayerLogin", root, playersData)
  24. Citizen

    Tables

    You say that you want to GET the resource state but you are pasting a code that tries to INSERT. In don't understand how you could end with that. Based on this only sentence: Here is how to do it: local state = resources[resource].state
  25. It was obviously implicit because of the context: So it means that the gui is probably poping up when the player is in the marker of a house (automatically, or using a key or even a command). He didn't mention anything about the cursor (that could have been used to click on the marker and so we would be able to get the marker using the event parameters). We could also find the closest house marker using the player position, but I doubt it was what he wants. That's why I assumed he wanted to get the a house marker which have been created on the server-side and in which the player should stand in to show the gui. That being said, we can also send the marker in the triggerClientEvent that opens the gui.
×
×
  • Create New...