Mizudori
Members-
Posts
75 -
Joined
-
Last visited
Everything posted by Mizudori
-
When I enter car with getVehicleCompatibleUpgrades is doesn't show me a compatibleUpgrades it shows some upgrades for other cars. It shows compatible list of spoilers for banshee when banshee doesn't have spoilers to upgrade. function scriptOnPlayerEnterVehicle ( invehicle, seat, jacked ) local upgrades = getVehicleCompatibleUpgrades ( invehicle ) for upgradeKey, upgradeValue in ipairs ( upgrades ) do outputChatBox ( getVehicleUpgradeSlotName ( upgradeValue ) .. ": " .. upgradeValue ) end end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), scriptOnPlayerEnterVehicle ) Proof that I am not insane here 1162 spl_a_j_b Spoiler Alien Jester 1163 spl_c_u_b Spoiler X-Flow Uranus
-
it works fine for me. I mispelled local there. Try this. This one is tested function MarkerHit( hitElement, matchingDimension ) -- hitElement = to element that hit the marker if(getElementType(hitElement) == "player")then -- check if element is player local veh = getPedOccupiedVehicle(hitElement) -- if yes check if he is in vehicle if(veh)then -- if yes then veh = the player vehicle local x = setVehicleWheelStates(veh,2,2,-1,-1) -- example of change wheel states if(x)then -- check if works outputChatBox("success") end else return 0 -- if no, do end and do nothing end end end addEventHandler( "onMarkerHit", change_w, MarkerHit )
-
ok as If I did not know that.
-
This is one of possibilities , When car is created or bought. You take owner name + random integer and set is as car_id. Or you can just make the same thing with out owner and you random integer but you need to check if that random integer is not is use already. setElementData(vehicle,"car_id",car_id) than just retriev element by car_id and add new values, create column in sql with car_id + other data attached to it, and select data and vehicle by it's car_id
-
This is server side event change_w = createMarker (x, y, z, "checkpoint", 1, 255,0,0,255) <== x,y,z position of marker function MarkerHit( hitElement, matchingDimension ) <-- hitElement = to element that hit the marker if(getElementType(hitElement) == "player")then <-- check if element is player local veh = getPedOccupiedVehicle(hitElement) <-- if yes check if he is in vehicle if(veh)then <-- if yes then veh = the player vehicle loca x = setVehicleWheelStates(veh,2,2,-1,-1) <-- example of change wheel states if(x)then <-- check if works outputChatBox("success") end else return 0 <-- if no, do end and do nothing end end end addEventHandler( "onMarkerHit", change_w, MarkerHit )
-
Oh so you are using SQLQuery to get info about vehicle.. so this won't work local x,y,z = getElementPosition(veh) local c1,c2,c3,c4 = getVehicleColor(veh) local upgrades = getVehicleUpgrades(veh) local mode = getElementModel(veh) Sorry I am using mysql most of the time so don't know SQL function here. If this is the same as mysql just try this local veh = executeSQLQuery("SELECT * FROM private_vehicles WHERE vehicleID = ?",tonumber(vehicleID)) local model = veh["getvehicleModel"]
-
Can you copy paste the whole function?
-
If you are using it in function respawnExplodedVehicle() you can just use source instead of veh local x,y,z = getElementPosition(veh) local c1,c2,c3,c4 = getVehicleColor(veh) local upgrades = getVehicleUpgrades(veh) <--- you need to use for cuz this is a table. local mode = getElementModel(veh)
-
function some_function(button, state) if (source == some_btn) then triggerServerEvent("name_of_event", getLocalPlayer(),arg,arg2) end addEventHandler ( "onClientGUIClick",some_btn, some_function,false)
-
What is this code all about ? You are taking this info from some table ? if you are taking it from element you need to use getElementPosition, GetVehicleColor, getVehicleModel, getElementModel and you dont need to make it to string and number posision is already in int, and other in strings
-
"some_name" author"Fishy" type="script" version"1.3.2" />
-
@Lek this function should be real time for players hp or vehicle?
-
I think it will be easier to help if you will say what your function should do. For example you can get vehicle element from onMarkerHit or OnVehicleEnter. front left -> Flat local veh = createVehicle(422,x,y,z) setVehicleWheelStates(veh,1,-1,-1,-1) right rear -> fallen off local veh = createVehicle(422,x,y,z) setVehicleWheelStates(veh,-1,-1,-1,2) front left -> fallen off and rear left -> fallen off local veh = createVehicle(422,x,y,z) setVehicleWheelStates(veh,2,2,-1,-1)
-
Still nothing, this is interesting is shows that table upgrades is empty. I am using debugger 3 no errors. screens from 2 vehicles function table.empty( a ) if type( a ) ~= "table" then return false end return not next( a ) end function scriptOnPlayerEnterVehicle ( theVehicle, seat, jacked ) local upgrades = getVehicleUpgrades ( theVehicle ) for _, upgrade in ipairs ( upgrades ) do outputChatBox ( getVehicleUpgradeSlotName ( upgrade ) .. ": " .. upgrade ) end local isempty = table.empty(upgrades) if(isempty)then outputChatBox("Table is empty") else outputChatBox("Table is not emepty") end end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), scriptOnPlayerEnterVehicle ) I really don't understand what is wrong, for dem tries I tried to use "getVehicleCompatibleUpgrades". It works fine. It shows that table is not empty and retrieves tables. function table.empty( a ) if type( a ) ~= "table" then return false end return not next( a ) end function scriptOnPlayerEnterVehicle ( invehicle, seat, jacked ) local upgrades = getVehicleCompatibleUpgrades ( invehicle ) for upgradeKey, upgradeValue in ipairs ( upgrades ) do outputChatBox ( getVehicleUpgradeSlotName ( upgradeValue ) .. ": " .. upgradeValue ) end local isempty = table.empty(upgrades) if(isempty)then outputChatBox("Table is empty") else outputChatBox("Table is not emepty") end end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), scriptOnPlayerEnterVehicle )
-
Hi, so I used the function which you gave me.. I copied paste it as the previous server-side function scriptOnPlayerEnterVehicle ( theVehicle, seat, jacked ) local upgrades = getVehicleUpgrades ( theVehicle ) for upgradeKey, upgradeValue in ipairs ( upgrades ) do outputChatBox ( getVehicleUpgradeSlotName ( upgradeKey - 1 ) .. ": " .. upgradeValue ) end end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), scriptOnPlayerEnterVehicle ) when I enter any car I doesn't show the upgrades now -,- For first I tought it's maybe me doing something wrong with function but when I tried simple function scriptOnPlayerEnterVehicle ( theVehicle, seat, jacked ) outputChatBox ("Does it works?") end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), scriptOnPlayerEnterVehicle ) It shown me a message in chatbox.
-
setWeaponProperty("colt 45", "std", "flags", 0x000800)
-
Hey man it is New Year here and maybe I am to drunk but where is ur addLevel declared. It's says that your level var which is addlevel or defaultlevel is empty
-
What do you mean by enter the vehicle? I think the reason of this is creating vehicle on client side. If(carName) then local y = y+2 triggerServerEvent("somename",getRootElement(),carModel,x,y,z) end and creave vehicle server side with carModel var. server side function create(CarModel,x,y,z) createVehicle(CarModel,x,y,z) end addEvent("somename",true) addEventHandler("somename",getRootElement(),create) https://wiki.multitheftauto.com/wiki/CreateVehicle here is the reason why. Note: Vehicles (and other elements) created client-side are only seen by the client that created them, aren't synced and players cannot enter them. They are essentially for display only.
-
Hey man, maybe check what is in the carName var by function cVeh () local x, y, z = getElementPosition (localPlayer) carModel = guiComboBoxGetItemText ( combo, guiComboBoxGetSelected ( combo ) ) carName = getVehicleModelFromName( carModel ) if (carName) then outputChatBox("name: "..CarName.."Mode: "..carModel) <-- and check if this is model of vehicle which you choose on wiki site. createVehicle(carModel, x, y + 2, z) end end
-
This should give u an idea what I have in mind up there. show_btn = guiCreateButton ( 0.2, 0.5, 0.1, 0.1, "Show", true) hide_btn = guiCreateButton ( 0.5, 0.5, 0.1, 0.1, "Hide", true) guiSetVisible(show_btn,true) guiSetVisible(hide_btn,true) showCursor(true,false) local screenWidth, screenHeight = guiGetScreenSize ( ) -- Get the screen resolution (width and height) function show_f(button, state) if (source == show_btn) then some_objectX,some_objectY,some_objectZ = 123.0, 32.000, 12 <-- you need to declared object position here, every new button = new position addEventHandler ( "onClientRender", root, show_dis ) guiSetVisible(show_btn,false) guiSetVisible(hide_btn,true) end end addEventHandler ( "onClientGUIClick",show_btn,show_f,false) function hide_f(button, state) if (source == hide_btn) then removeEventHandler( "onClientRender", root, show_dis ) guiSetVisible(show_btn,true) guiSetVisible(hide_btn,false) end end addEventHandler ( "onClientGUIClick", hide_btn,hide_f,false) function show_dis () local x,y,z=getElementPosition(getLocalPlayer ( )) <-- local player position it's need to be here if you want to get continuous update beetween object and player dis = getDistanceBetweenPoints3D ( x, y, z, some_objectX,some_objectY,some_objectZ ) dxDrawText ( math.floor(dis), 44, screenHeight - 43, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "pricedown" ) end Just copy and paste it if you want it to show only for period of time use timer, delete hide_f and hide_btn and I suggest you to disable clicked button for the 5s. If you will have more than 1 object button is better to use the if(trigger) then .. end(in show_dis function), instand of remove and add eventHandler. function show_f(button, state) if (source == show_btn) then some_objectX,some_objectY,some_objectZ = 123.0, 32.000, 12 addEventHandler ( "onClientRender", root, show_dis ) setTimer ( function() removeEventHandler( "onClientRender", root, show_dis ) end, 5000, 1 ) end end addEventHandler ( "onClientGUIClick",show_btn,show_f,false)
-
Yeah but I mean what this script should do exactly?
-
Where is ur wx,wy,wz declared? It says that your wx is empty, prolly wy and wz aswell. Dunno what ur scipt need to do but if this is somethig like start to show meters after button click, you cannot use onClientRender with out any trigger for it.
-
Oh yeah I am so dumb Thank for the help ^^ Next time I need to read the description more carefully
-
Hi I know this might be and offtopic but why you don't use the mta wiki function to connect to mysql and insert data cn = dbConnect (info_about_mysql) <-- u can share it for all lua files function AddVehicle() local value = some short of unique key for your vehicle local value1 and value 2 are the info about car which you want to insert query = dbQuery(cn,"SELECT * FROM vehicle WHERE column_name =?",value) result = dbPoll ( query, -1 ) if(result)then dbExec(cn, "UPDATE statment here") <-- if vehicle is in db already else dbExec(cn, "INSERT INTO vehicle (column1,column2) VALUES (?,?)",value1,value2) <-- if not, insert end end I think it's simple than your code
-
Hello, last day I decided to write script for car shop upgrades. So I went to wiki so see if there is any good function which will help me out with it and I did find the getVehicleCompatibleUpgrades(). I created lua script to test it up (the script from example on wiki). When I entered the car(banshee) it shown me a spoiler which cleary are not part of this car. When I entered other car which doesn't have a spoilers it shown me spoilers as well. I did not change any line in the code I copied paste it. This is how my lua file looks like. It's server side. meta script is typ of "server" function scriptOnPlayerEnterVehicle ( invehicle, seat, jacked ) local upgrades = getVehicleCompatibleUpgrades ( invehicle ) for upgradeKey, upgradeValue in ipairs ( upgrades ) do outputChatBox ( getVehicleUpgradeSlotName ( upgradeValue ) .. ": " .. upgradeValue ) end end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), scriptOnPlayerEnterVehicle ) I am doing something wrong or this funcions doesn't work correclty?
