dudeks Posted January 30, 2012 Posted January 30, 2012 (edited) WItam. Mam denerwujący mnie problem. Nie mogę odczytać nazwy teamu po id. Powinno odczytać nazwe teamu w kodzie z: teams[car[auto]["owner"]]["name"] local veh = createVehicle(v["model"], v["x"], v["y"], v["z"], v["rx"], v["ry"], v["rz"], "RPG"..tostring(v["id"]), true, tonumber(v["var1"]), tonumber(v["var2"])) car[veh] = { } car[veh]["owner"] == tonumber(v["owner"]) owner to id teamu, do ktorego pojazd należy. 'Przypisywanie' id do teamu: local id = tonumber(data["id"]) teams[id] = {} teams[id]["name"] = tostring(data["name"]) teams[id]["team"] = createTeam("[iD: "..teams[id]["id"].."] "..teams[id]["name"], teams[id]["r"], teams[id]["g"], teams[id]["b"]) Za każdym razem zwraca nil. Edited January 30, 2012 by Guest
dzek (varez) Posted January 30, 2012 Posted January 30, 2012 a czy car[veh]["owner"] nie jest stringiem zamiast intem? przy przypisaniu jest to int, nie wiadomo co jest przy odczycie. zauważ: http://ideone.com/oBnVQ Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
dudeks Posted January 30, 2012 Author Posted January 30, 2012 Dodałem trochę więcej kodu. Przy odczycie: teams[tonumber(car[auto]["owner"])]["name"] też zwraca nil. print(teams[car[a]["owner"]]["name"]) print(teams[tostring(car[a]["owner"])]["name"]) print(teams[tonumber(car[a]["owner"])]["name"]) Przy każdym zwraca nil. O dziwo, teams[1]["name"] też zwraca nil
dzek (varez) Posted January 30, 2012 Posted January 30, 2012 co w mta robi print? wpisuje w konsole, czy co? to może teams jest jakoś ograniczony przez local albo coś w tym stylu? zobacz co zwraca teams[1] oraz w ogóle teams edit: moment, człowieku. linia 4 Twojego kodu: car[veh]["owner"] == tonumber(v["owner"]) Tu robisz porównanie, nie przypisanie! To Ci się w ogóle uruchamia tak? Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
dudeks Posted January 30, 2012 Author Posted January 30, 2012 (edited) print("teams: "..tostring(teams)) print("teams[1]: "..tostring(teams[1])) teams: table: 02F28668 teams[1]: nil Edit: Co do tej 4 linii, literowka, bo pisalem to z glowy. W kodzie mam bez tego, uruchamia sie. Edited January 30, 2012 by Guest
dzek (varez) Posted January 30, 2012 Posted January 30, 2012 tam gdzie masz: local id = tonumber(data["id"]) -- tutaj dopisz jakis print/cokolwiek dla id -- wygląda na to, że tu masz błąd teams[id] = {} Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
dudeks Posted January 30, 2012 Author Posted January 30, 2012 print("Id: "..id..", type: "..type(id)) Id: 1, type: number
dudeks Posted January 31, 2012 Author Posted January 31, 2012 Rozwiązanie problemu okazało się być banalne. Nie tworze pojazdów ani teamów jako osobną funkcję z resourcestartem. Mam jedną funkcję i w niej mam wczytywanie, wozy wczytywały się przed teamami, więc nie miało skąd pobrać danych. Wystarczyło (w moim przypadku) zamienić: vehicles.loadOnStart() team.loadTeams() na team.loadTeams() vehicles.loadOnStart()
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now