ali Posted January 14, 2013 Posted January 14, 2013 client function firing(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) if getElementType(hitElement)== "Vehicle" then triggerServerEvent("onFire", getRootElement()) end end addEventHandler("onClientPlayerWeaponFire", getRootElement(), firing ) server function iii( ) local ils = getPedStat( localPlayer, 122) setPedStat( localPlayer, 122, ils+1 ) end function lll( ) local ilss = getPedStat( localPlayer, 123) setPedStat( localPlayer, 123, ilss+1 ) end function ooo( ) local il = getPedStat( localPlayer, 122) setPedStat( localPlayer, 124, il+1 ) end function add(theVehicle) if (getVehicleType ( theVehicle ) == "Automobile")then addEventHandler("onVehicleExplode", getRootElement, iii) else if (getVehicleType ( theVehicle ) == "Helicopter")then addEventHandler("onVehicleExplode", getRootElement, ooo) else if (getVehicleType ( theVehicle ) == "Boat")then addEventHandler("onVehicleExplode", getRootElement, lll) end end end end addEvent("onFire",true) addEventHandler("onFire", getRootElement(), add ) error In Client : [2013-01-14 16:49:16] WARNING: ali\logsss.lua:2: Bad argument @ 'getElementType' [2013-01-14 16:49:16] WARNING: ali\logsss.lua:2: Bad argument @ 'getElementType' [2013-01-14 16:49:16] WARNING: ali\logsss.lua:2: Bad argument @ 'getElementType'
MR.S3D Posted January 14, 2013 Posted January 14, 2013 localPlayer not use in server side just in client side
ali Posted January 14, 2013 Author Posted January 14, 2013 still its giving [2013-01-14 17:50:05] WARNING: ali\logsss.lua:57: Bad argument @ 'getElementType
MR.S3D Posted January 14, 2013 Posted January 14, 2013 still its giving[2013-01-14 17:50:05] WARNING: ali\logsss.lua:57: Bad argument @ 'getElementType Client function firing( _, _, _, _, _, _, hitElement) if hitElement and getElementType( hitElement ) == "Vehicle" then triggerServerEvent("onFire", getRootElement()) end end addEventHandler("onClientPlayerWeaponFire", getRootElement(), firing )
ali Posted January 14, 2013 Author Posted January 14, 2013 now there are no errors but still here is the full codes client: marker55 = createMarker( 1000, 1000, 47,"cylinder", 1.5, 255, 225, 0 ) GUIEditor = { window = {}, } GUIEditor.window[1] = guiCreateWindow(321, 142, 694, 532, "Stats", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 1.00) Cars = guiCreateLabel(8, 42, 325, 36, "", false, GUIEditor.window[1]) guiSetFont(Cars, "default-bold-small") Helicopters = guiCreateLabel(10, 110, 325, 36, "", false, GUIEditor.window[1]) guiSetFont(Helicopters, "default-bold-small") Boats = guiCreateLabel(10, 176, 325, 36, "", false, GUIEditor.window[1]) guiSetFont(Boats, "default-bold-small") BikeSkills = guiCreateLabel(10, 248, 325, 36, "", false, GUIEditor.window[1]) guiSetFont(BikeSkills, "default-bold-small") CycleSkills = guiCreateLabel(10, 328, 325, 36, "", false, GUIEditor.window[1]) guiSetFont(CycleSkills, "default-bold-small") Muscles = guiCreateLabel(10, 415, 325, 36, "", false, GUIEditor.window[1]) guiSetFont(Muscles, "default-bold-small") guiSetVisible(GUIEditor.window[1], false) showCursor(false) function MarkerHit (hitPlayer) if ( hitPlayer == localPlayer ) then guiSetVisible (GUIEditor.window[1], true) showCursor (true) end end addEventHandler ( "onClientMarkerHit", marker55, MarkerHit ) addEventHandler("onClientRender", root, function () local heli = getPedStat( localPlayer, 124) local car = getPedStat( localPlayer, 122) local boa = getPedStat( localPlayer, 123) local bike = getPedStat( localPlayer, 229) local cycle = getPedStat( localPlayer, 230) local Muss = getPedStat( localPlayer, 23) guiSetText(Cars, "Cars Destroyed: " ..car) guiSetText(Helicopters, "Helicopters Destroyed: " ..heli) guiSetText(Boats, "Boats Destroyed: " ..boa) guiSetText(BikeSkills, "Bike Skills: " ..bike) guiSetText(CycleSkills, "cycle Skills : " ..cycle) guiSetText(Muscles, "Your Muscles: " ..Muss) end ) function firing( _, _, _, _, _, _, hitElement) if hitElement and getElementType( hitElement ) == "Vehicle" then triggerServerEvent("onFire", getRootElement()) end end addEventHandler("onClientPlayerWeaponFire", getRootElement(), firing ) server: function iii( ) local ils = getPedStat( source, 122) setPedStat( localPlayer, 122, ils+1 ) end function lll( ) local ilss = getPedStat( source, 123) setPedStat( localPlayer, 123, ilss+1 ) end function ooo( ) local il = getPedStat( source, 122) setPedStat( localPlayer, 124, il+1 ) end function add() if (getVehicleType ( source ) == "Automobile")then addEventHandler("onVehicleExplode", getRootElement, iii) else if (getVehicleType ( source ) == "Helicopter")then addEventHandler("onVehicleExplode", getRootElement, ooo) else if (getVehicleType ( source ) == "Boat")then addEventHandler("onVehicleExplode", getRootElement, lll) end end end end addEvent("onFire",true) addEventHandler("onFire", getRootElement(), add ) [url=http://speedy.sh/DqzSy/mta-screen-2013-01-14-18-09-31.png]http://speedy.sh/DqzSy/mta-screen-2013- ... -09-31.png[/url]
csiguusz Posted January 14, 2013 Posted January 14, 2013 And what is you problem? function add() if (getVehicleType ( source ) == "Automobile")then addEventHandler("onVehicleExplode", getRootElement, iii) else if (getVehicleType ( source ) == "Helicopter")then addEventHandler("onVehicleExplode", getRootElement, ooo) else if (getVehicleType ( source ) == "Boat")then addEventHandler("onVehicleExplode", getRootElement, lll) end end end end Adding an event handler on each shot is not a good idea... function firing( _, _, _, _, _, _, hitElement) if hitElement and getElementType( hitElement ) == "Vehicle" then triggerServerEvent("onFire", getRootElement()) end end Use hitElement instead of getRootElement() as the source of the event if you want to get the type of the vehicle on server side. And the element type can't be "Vehicle", but "vehicle".
ali Posted January 14, 2013 Author Posted January 14, 2013 [2013-01-14 18:39:20] WARNING: ali\logss.lua:2: Bad 'ped' pointer @ 'getPedStat'(1) [2013-01-14 18:39:20] ERROR: ali\logss.lua:3: attempt to perform arithmetic on local 'ils' (a boolean value)
MR.S3D Posted January 14, 2013 Posted January 14, 2013 Client marker55 = createMarker( 1000, 1000, 47,"cylinder", 1.5, 255, 225, 0 ) GUIEditor = { window = {}, } GUIEditor.window[1] = guiCreateWindow(321, 142, 694, 532, "Stats", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 1.00) Cars = guiCreateLabel(8, 42, 325, 36, "", false, GUIEditor.window[1]) guiSetFont(Cars, "default-bold-small") Helicopters = guiCreateLabel(10, 110, 325, 36, "", false, GUIEditor.window[1]) guiSetFont(Helicopters, "default-bold-small") Boats = guiCreateLabel(10, 176, 325, 36, "", false, GUIEditor.window[1]) guiSetFont(Boats, "default-bold-small") BikeSkills = guiCreateLabel(10, 248, 325, 36, "", false, GUIEditor.window[1]) guiSetFont(BikeSkills, "default-bold-small") CycleSkills = guiCreateLabel(10, 328, 325, 36, "", false, GUIEditor.window[1]) guiSetFont(CycleSkills, "default-bold-small") Muscles = guiCreateLabel(10, 415, 325, 36, "", false, GUIEditor.window[1]) guiSetFont(Muscles, "default-bold-small") guiSetVisible(GUIEditor.window[1], false) showCursor(false) function MarkerHit (hitPlayer) if ( hitPlayer == localPlayer ) then guiSetVisible (GUIEditor.window[1], true) showCursor (true) end end addEventHandler ( "onClientMarkerHit", marker55, MarkerHit ) addEventHandler("onClientRender", root, function () local heli = getPedStat( localPlayer, 124) local car = getPedStat( localPlayer, 122) local boa = getPedStat( localPlayer, 123) local bike = getPedStat( localPlayer, 229) local cycle = getPedStat( localPlayer, 230) local Muss = getPedStat( localPlayer, 23) guiSetText(Cars, "Cars Destroyed: " ..car) guiSetText(Helicopters, "Helicopters Destroyed: " ..heli) guiSetText(Boats, "Boats Destroyed: " ..boa) guiSetText(BikeSkills, "Bike Skills: " ..bike) guiSetText(CycleSkills, "cycle Skills : " ..cycle) guiSetText(Muscles, "Your Muscles: " ..Muss) end ) function firing( _, _, _, _, _, _, hitElement) if hitElement and getElementType( hitElement ) == "Vehicle" then triggerServerEvent("onFire", getRootElement(),hitElement) end end addEventHandler("onClientPlayerWeaponFire", getRootElement(), firing ) Server function iii(player) local ils = getPedStat(player, 122) setPedStat( player, 122, ils+1 ) end function lll( ) local ilss = getPedStat( player, 123) setPedStat( player, 123, ilss+1 ) end function ooo(player) local il = getPedStat( player, 122) setPedStat( player, 124, il+1 ) end function add(vhe) if (getVehicleType ( vhe ) == "Automobile")then iii(source) elseif (getVehicleType ( vhe ) == "Helicopter")then ooo(source) elseif (getVehicleType ( vhe ) == "Boat")then lll(source) end end addEvent("onFire",true) addEventHandler("onFire", getRootElement(), add )
csiguusz Posted January 14, 2013 Posted January 14, 2013 client: function firing( _, _, _, _, _, _, hitElement) if hitElement and getElementType( hitElement ) == "vehicle" then triggerServerEvent("onFire", getLocalPlayer(), hitElement) end end addEventHandler("onClientPlayerWeaponFire", getRootElement(), firing ) server: function add( veh ) if (getVehicleType ( veh) == "Automobile")then iii(source) elseif (getVehicleType ( veh ) == "Helicopter")then ooo(source) elseif (getVehicleType ( veh ) == "Boat")then lll(source) end end addEvent("onFire",true) addEventHandler("onFire", getRootElement(), add )
ali Posted January 14, 2013 Author Posted January 14, 2013 this worked a bit but this makes 1 car detroying like 35 cars
csiguusz Posted January 14, 2013 Posted January 14, 2013 this worked a bit but this makes 1 car detroying like 35 cars Hm? Could you please explain this, because i don't understand.
ali Posted January 14, 2013 Author Posted January 14, 2013 I mean when i destroy one car it shows that i destroyed 35 cars and when i destroyed 2 cars it showed 70 cars in the Gui given above
csiguusz Posted January 14, 2013 Posted January 14, 2013 I mean when i destroy one car it shows that i destroyed 35 cars and when i destried 2 cars it showed 70 car in the Gui given above This is because it gives you points every time you shoot the specified vehicle, not only when it's destroyed. Use an another event instead of onClientPlayerWeaponFire, like onClientVehicleExplode (client-side) or onVehicleExplode (server-side).
ali Posted January 14, 2013 Author Posted January 14, 2013 if i use onClientVehicleExplode or onVehicleExplode then how will it add the players stat?
csiguusz Posted January 14, 2013 Posted January 14, 2013 if i use onClientVehicleExplode or onVehicleExplode then how will it add the players stat? Oh, you are right, with those events you can't check who destroyed a vehicle...
csiguusz Posted January 14, 2013 Posted January 14, 2013 Yes So, in this case I dont have any idea... it would be hard to find out who actually destroyed a vehicle.
csiguusz Posted January 14, 2013 Posted January 14, 2013 hmm.. so what now Start thinking I'm doing it too.
MR.S3D Posted January 14, 2013 Posted January 14, 2013 try with this Client marker55 = createMarker( 1000, 1000, 47,"cylinder", 1.5, 255, 225, 0 ) GUIEditor = { window = {}, } GUIEditor.window[1] = guiCreateWindow(321, 142, 694, 532, "Stats", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 1.00) Cars = guiCreateLabel(8, 42, 325, 36, "", false, GUIEditor.window[1]) guiSetFont(Cars, "default-bold-small") Helicopters = guiCreateLabel(10, 110, 325, 36, "", false, GUIEditor.window[1]) guiSetFont(Helicopters, "default-bold-small") Boats = guiCreateLabel(10, 176, 325, 36, "", false, GUIEditor.window[1]) guiSetFont(Boats, "default-bold-small") BikeSkills = guiCreateLabel(10, 248, 325, 36, "", false, GUIEditor.window[1]) guiSetFont(BikeSkills, "default-bold-small") CycleSkills = guiCreateLabel(10, 328, 325, 36, "", false, GUIEditor.window[1]) guiSetFont(CycleSkills, "default-bold-small") Muscles = guiCreateLabel(10, 415, 325, 36, "", false, GUIEditor.window[1]) guiSetFont(Muscles, "default-bold-small") guiSetVisible(GUIEditor.window[1], false) showCursor(false) function MarkerHit (hitPlayer) if ( hitPlayer == localPlayer ) then guiSetVisible (GUIEditor.window[1], true) showCursor (true) end end addEventHandler ( "onClientMarkerHit", marker55, MarkerHit ) addEventHandler("onClientRender", root, function () local heli = getPedStat( localPlayer, 124) local car = getPedStat( localPlayer, 122) local boa = getPedStat( localPlayer, 123) local bike = getPedStat( localPlayer, 229) local cycle = getPedStat( localPlayer, 230) local Muss = getPedStat( localPlayer, 23) guiSetText(Cars, "Cars Destroyed: " ..car) guiSetText(Helicopters, "Helicopters Destroyed: " ..heli) guiSetText(Boats, "Boats Destroyed: " ..boa) guiSetText(BikeSkills, "Bike Skills: " ..bike) guiSetText(CycleSkills, "cycle Skills : " ..cycle) guiSetText(Muscles, "Your Muscles: " ..Muss) end ) function firing( _, _, _, _, _, _, hitElement) if hitElement and getElementType( hitElement ) == "Vehicle" then setElementData( hitElement,"VehicleExplode", getLocalPlayer(), true) end end addEventHandler("onClientPlayerWeaponFire", getRootElement(), firing ) Server addEventHandler("onVehicleExplode", getRootElement(), function() local Killer = getElementData ( source, "VehicleExplode" ) if Killer and getElementType(Killer)=="player" then if (getVehicleType ( source ) == "Automobile")then iii(Killer) elseif (getVehicleType ( source ) == "Helicopter")then ooo(Killer) elseif (getVehicleType ( source ) == "Boat")then lll(Killer) end end setElementData( source,"VehicleExplode", nil, true) end ) function iii(player) local ils = getPedStat(player, 122) setPedStat( player, 122, ils+1 ) end function lll( ) local ilss = getPedStat( player, 123) setPedStat( player, 123, ilss+1 ) end function ooo(player) local il = getPedStat( player, 122) setPedStat( player, 124, il+1 ) end
MR.S3D Posted January 14, 2013 Posted January 14, 2013 SERVER function iii(player) local ils = getPedStat(player, 122) setPedStat( player, 122, ils+1 ) end function lll( ) local ilss = getPedStat( player, 123) setPedStat( player, 123, ilss+1 ) end function ooo(player) local il = getPedStat( player, 122) setPedStat( player, 124, il+1 ) end addEventHandler("onVehicleExplode", getRootElement(), function() local Killer = getElementData ( source, "VehicleExplode" ) if Killer and getElementType(Killer)=="player" then if (getVehicleType ( source ) == "Automobile")then iii(Killer) elseif (getVehicleType ( source ) == "Helicopter")then ooo(Killer) elseif (getVehicleType ( source ) == "Boat")then lll(Killer) end end end )
csiguusz Posted January 14, 2013 Posted January 14, 2013 client: function firing( _, _, _, _, _, _, hitElement) if hitElement and getElementType( hitElement ) == "vehicle" and getElementHealth(hitElement) <= 300 and not getElementData(hitElement,"lastDamageFrom") then setElementData(hitElement,"lastDamageFrom",getLocalPlayer()) end end addEventHandler("onClientPlayerWeaponFire", getRootElement(), firing ) server: function add() local player = getElementData(source,"lastDamageFrom") if player then if (getVehicleType ( source ) == "Automobile")then iii(player) elseif (getVehicleType ( source ) == "Helicopter")then ooo(player) elseif (getVehicleType ( source ) == "Boat")then lll(player) end end end addEventHandler("onVehicleExplode", getRootElement(), add ) This is maybe not the most efficient solution, but should work.
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