Jump to content

Mann56

Members
  • Posts

    306
  • Joined

  • Last visited

Everything posted by Mann56

  1. Can you show where you initialized ttcounter?
  2. Hey guys, I am working on a vehicle-system. I have seen many servers having vehicle shops have images of the car when clicked to preview before buying the car. I have made a gridlist and i want to do like : Whenever a guy clicks a car he can see the car in the background. I thought of using images but they would be too static... Is there any way to also make vehicles visible when their name is clicked upon and if possible some rotation to them to make a feel like a real showroom?
  3. If you have not added those events clientside, you need to add them in the client like this : addEvent("onClientSetMapName",true) -- Here you have to add the event name, true means that the event has been added clientside. -- now call the event using addEventHandler like this addEventHandler("onClientSetMapName",theElement,your_function) Do this for every event. You don't have to search the meta for events Refer these : triggerServerEvent addEvent addEventHandler triggerClientEvent Hope it helps...
  4. Try this: local client = getLocalPlayer() local rootElement = getRootElement() local theMarker = nil local r, b, g = getMarkerColor vehicle.window = guiCreateWindow(550,560,200,200, "Vehicle System", false) guiWindowSetSizable(vehicle_selector_window, false) guiSetVisible(vehicle.window,false) vehicle.grid = guiCreateGridList(0,20,190,170, false, vehicle.window) local key = guiGridListAddColumn(vehicle.grid, "Key", 0.20) local name = guiGridListAddColumn(vehicle.grid, "Name", 0.65) showCursor(false) theMarker = marker guiGridListClear(vehicle_selector_grid) for i,v in pairs(vehiclesTable) do local row = guiGridListAddRow(vehicle_selector_grid) guiGridListSetItemText(vehicle.grid, row, key, tostring(row+1), false, false) guiGridListSetItemText(vehicle.grid, row, name, getVehicleNameFromModel(v), false, false) end function openGui(vehiclesTable,marker) guiSetVisible(vehicle_selector_window,true) function spawnv(button, press) if(press) then if(button == "1") then local vehicleName = guiGridListGetItemText(vehicle_selector_grid, row,name) triggerServerEvent("vehicle_spawn",client,client,getVehicleModelFromName(vehicleName),theMarker) end if(button == "2") then triggerServerEvent("vehicle_spawn",client,client,getVehicleModelFromName(vehicleName),theMarker) end if(button == "3") then triggerServerEvent("vehicle_spawn",client,client,getVehicleModelFromName(vehicleName),theMarker) end if(button == "4") then x, y, z = getElementPosition(localPlayer) triggerServerEvent("vehicle_spawn",client,client,getVehicleModelFromName(vehicleName),theMarker) end if(button == "5") then triggerServerEvent("vehicle_spawn",client,client,getVehicleModelFromName(vehicleName),theMarker) end if(button == "6") then x, y, z = getElementPosition(localPlayer) triggerServerEvent("vehicle_spawn",client,client,getVehicleModelFromName(vehicleName),theMarker) end end if(button == "7") then triggerServerEvent("vehicle_spawn",client,client,getVehicleModelFromName(vehicleName),theMarker) end end addEventHandler("onClientKey", getRootElement(), spawnv) end addEvent("markerHittted", true) addEventHandler("markerHittted", getRootElement(), openGui) function hideGui() guiSetVisible(vehicle_selector_window,false) removeEventHandler("onClientKey", getRootElement(), spawnv) end addEvent("markerLeavved", true) addEventHandler("markerLeavved", getRootElement(), hideGui) All i did was set the lines in order , try it.
  5. 'row' argument in guiGridListGetItemText(vehicle_selector_grid, row,name) is undefined, same is with the third argument 'name' so the system takes them as nil.
  6. Hey guys, I recently learned SQL and am making my first resource running on SQLite. It is a vehicle-system and my question is... I have a table which contains some information about some cars and their cost,max speed,fuel etc. I want to get it in my database 'vehicles'. I know that we can do it easily by looping dbExec , but it will repeat the same process every time i restart the resource. How can i prevent this?
  7. First of all the variable test should not be local as you've called it in the function. Secondly the source you've mentioned might not be the player maybe use thePlayer. Sorry am not a computer can't check the code....
  8. Thanks for the idea of using timers, but JR10's method is also good And yeah, using any function or event in renders , it causes problems as the event/function gets triggered every time it renders the screen. When i used to refuel fuel from 100, it would increment upto 144 times in a single space click.
  9. Thank you dude, That's cool and it will surely help!
  10. I set the fuel data inside the render function as i want it to function well before i input fuel, so whenever it refuels it starts from 100. I tried the first thing, but when i trigger the function to refuel when the key is pressed, it increments the fuel by the times it renders. The second thing, i think it will be good but how can i slow it down?
  11. Oh yeah, my bad, i'll remove the triggerServerEvent.
  12. As Overkillz and Olle Risk said, for an exp system, you can use setElementData getElementData and then save the data using getAccountData setAccountData
  13. Hey guys, I was making a fuel system and while making a typical refuel station, i encountered this problem, when i press space to refuel, it increments the no every time it renders ... How can i prevent this from happening? Here is the client code : sx_ , sy_ = guiGetScreenSize () sx, sy = sx_/1366 , sy_/768 fuel = 100000 fuelprice = 3 vehfuel = 100 totvehfuel = 150 state = "true" fueltype = "petrol" totfuel = 1000 function refuelTheVeh(cmd,dn,veh1) fuel = getElementData(veh1,"fuel") setElementData(veh1,"fuel",fuel+1) outputChatBox(""..fuel.."",255,255,0) end -- now lets draw the dxGui when a marker is hit function drawMarkerGUI ( thePlayer ) dxDrawRectangle(sx*420,sy*230,sx*470,sy*280,tocolor(0,0,0,150)) dxDrawText ( "Fuel Station" , sx*560, sy*235, sx*490, sy*235, tocolor ( 255, 255, 0, 255 ), 1, "bankgothic" ) dxDrawText("Fuel Type : " .. fueltype .. "", sx*510,sy*290,sx*500,sy*240,tocolor(255,255,255,255),1 ,"bankgothic") dxDrawText("Price : $" .. fuelprice .. "", sx*510,sy*330,sx*500,sy*240,tocolor(255,255,255,255),1 ,"bankgothic") dxDrawText("Total Fuel : " ..totfuel.." litres", sx*470,sy*370,sx*500,sy*240,tocolor(255,255,255,255),1 ,"bankgothic") dxDrawText("Your Fuel : " ..vehfuel.."/"..totvehfuel.. " litres", sx*440,sy*410,sx*500,sy*240,tocolor(255,255,255,255),1 ,"bankgothic") local veh = isPedInVehicle( localPlayer ) if veh then engstate = true veh1 = getPedOccupiedVehicle (localPlayer) getEngineState = getVehicleEngineState(veh1) end if getEngineState == engstate then dxDrawText("Please switch off the engine", sx*435,sy*450,sx*500,sy*240,tocolor(255,255,0,255),0.95 ,"bankgothic") elseif getEngineState ~= engstate then setElementData(veh1,"fuel",100) dxDrawText("Press SPACE to refuel!", sx*475,sy*450,sx*500,sy*240,tocolor(255,255,0,255),0.95 ,"bankgothic") bindKey("space","up",refuelTheVeh,veh1) end end
  14. Thank you buddy it works : > I thought i should use the event in the loop but i thought maybe nested events won't work .. Nvm Thank you very much
  15. He means, when the player dies, it will trigger the event onPlayerWasted then check if the player was in team criminal or not by using getPlayerTeam Like : function getTheKiller (killer) team = getPlayerTeam ( killer ) if team == "Criminal" then -- now we must cancel his stars else -- now here we must not cancel the stars end end addEventHandler("onPlayerWasted",root,getTheKiller) Hope it helps : >
  16. Awesome dude, everything you said is useful! Specially in my computer practicals : >
  17. Mann56

    Function need

    Explain properly, how can a player become a box
  18. Hey guys, I have a bit of trouble when i want the marker to open where a car hit's it, it would trigger the gui. Server markercords = { {1944.58691, -1778.72266, 12.39060}, {1944.33765, -1773.98657, 12.39060}, {1944.48840, -1771.07495, 12.39060}, {1944.29260, -1767.30762, 12.38281}, } addEventHandler("onResourceStart",resourceRoot, function() for i, pos in ipairs(markercords) do local x,y,z = unpack(pos) fuelmarkers = createMarker(x,y,z,"cylinder",2,255,255,0,50) end end)h addEventHandler("onMarkerHit",fuelmarkers , function (thePlayer) if isElementWithinMarker(thePlayer,fuelmarker) then if isPedInVehicle(thePlayer) then triggerClientEvent(thePlayer,"showthedxGui",root) end end end ) Client: sx_ , sy_ = guiGetScreenSize () sx, sy = sx_/1366 , sy_/768 fuel = 100000 fuelprice = 3 vehfuel = 100 totvehfuel = 150 local veh = isPedInVehicle( localPlayer ) function drawRect ( thePlayer ) exports.topbarchat:sendClientMessage( "DOes COme",root,255,255,255,false,9) if veh == "true" then local getEngineState = getVehicleEngineState(tostring(veh)) end dxDrawRectangle(sx+420,sy+230,sx+470,sy+280,tocolor(0,0,0,150)) dxDrawText ( "Fuel Station" , sx+560, sy+235, sx+490, sy+235, tocolor ( 255, 255, 0, 255 ), 1, "bankgothic" ) dxDrawText("Total Fuel : " .. fuel .. "", sx+510,sy+290,sx+500,sy+240,tocolor(255,255,255,255),1 ,"bankgothic") dxDrawText("Price : $" .. fuelprice .. "", sx+510,sy+330,sx+500,sy+240,tocolor(255,255,255,255),1 ,"bankgothic") dxDrawText("Your Fuel : " .. vehfuel .."/"..totvehfuel.. "", sx+510,sy+370,sx+500,sy+240,tocolor(255,255,255,255),1 ,"bankgothic") if getEngineState == "true" then dxDrawText("Please switch off the engine", sx+510,sy+420,sx+500,sy+240,tocolor(255,255,255,255),1 ,"bankgothic") elseif getEngineState == "false" then dxDrawText("Press SPACE to refuel!", sx+510,sy+420,sx+500,sy+240,tocolor(255,255,255,255),1 ,"bankgothic") end end addEvent("showthedxGui",true) addEventHandler("showthedxGui",resourceRoot,function () exports.topbarchat:sendClientMessage( "Comes here?",root,255,255,255,true,9) addEventHandler("onClientRender",root,drawRect ) end ) Also i have another Question, do nested events work? Like the one i did in my client file , i have no idea if they work or not Note: The resource is still in development and it lacks some scripting but i want to proceed further only if this problem is fixed so i have no problem afterwards : > Thanks
  19. Hey guys, I might seem a noob but i can't get the co-ordinates out of the table to create a marker. Server file : markercords = { {1945.20874, -1778.62756, 13.39060}, {1944.33765, -1773.98657, 13.39060}, {1944.09851, -1771.35437, 13.39060}, {1944.29260, -1767.30762, 13.38281}, } addEventHandler("onResourceStart",resourceRoot, function () for i , marker in pairs(markercords) do createMarker(markercords,"cylinder",2,255,255,0,100) end end ) The problem is that when i execute the code, all three cords, go in one argument, i tried with x,y and z variables too but of no use : < Please help
  20. Mann56

    SQLite Error

    Oh, Thanks mate <3
  21. Mann56

    SQLite Error

    Hey there guys, I have a little syntax error with Sqlite : Here's my sql code : Server side error script : addEvent("deleteTheGroup",true) addEventHandler("deleteTheGroup",root, function (thePlayer,groupByName) local rankq = getElementData(client,"rank") if rankq == "owner" then local check = dbPoll(dbQuery(connect, "SELECT * FROM groups WHERE column1 = ?",tostring(groupByName)), -1) if type(check) == "table" and #check == 0 or not check then dbExec(connect, "DELETE FROM groups VALUES (?)",tostring(groupByName)) end outputChatBox("Group System : Successfully deleted the group!",client,255,255,0) else outputChatBox("You are not the owner!!",client,255,0,0) end end) Thanks....
×
×
  • Create New...