Jump to content

Crossy101

Members
  • Posts

    12
  • Joined

  • Last visited

Recent Profile Visitors

368 profile views

Crossy101's Achievements

Square

Square (6/54)

3

Reputation

  1. A quick idea would be to check what vehicle they enter and if it's in a certain type = "Bike" then save all their current weapons and ammo in an array and when they get off it add those weapons and ammo values back to the player!
  2. In the file CSGaccounts, within the weapons.lua the global variable "DB" was a nil value meaning it doesn't have any value associated to it.
  3. Lua doesn't really like OOP and it can make it it pretty slow an example of this is on the wikipedia page. --OOP start = getTickCount() a = 1 for i=1,1000000 do a = localPlayer.position end stop = getTickCount() print("variable", stop - start ) -- Time Taken: 1500ms --Structural start = getTickCount() b = nil for i=1,1000000 do b = getElementPosition(localPlayer) end stop = getTickCount() print("structural", stop - start ) -- Time Taken: 200ms
  4. Just add: SetTimer(5000, DestroyAllFagios, 1) to the bottom of the function!
  5. function DestroyAllFagios(playerSource) local allVehicles = getElementsByType("Vehicle") for i,v in ipairs(allVehicles) do if getElementModel(v) == 462 then local counter = 0 for seat, player in pairs(getVehicleOccupants(v)) do counter = counter + 1 end if counter == 0 then blowVehicle(v) end end end end addCommandHandler("destroyfagios", DestroyAllFagios) Something like this would work! Good Luck!
  6. You do understand it can be 12:00 for more than a few seconds right?? Just like real life!
  7. Well exactly you have figured out the problem, if it's not in a loop it's being called multiple times. One thing you should really learn to do is brighten up that attitude.
  8. Nope it will run a couple of times if it's either inside a loop or gets called again within a short amount of time the best thing to do is add some kind of boolean variable. Example: timehour, timeminute = getTime() debounce = false var = 0 if timehour == 12 and timeminute == 0 and debounce == false then var = var + 1 --I want to execute this line only once whenever the condition is true debounce = true end Hope this helps!
  9. function vehicle(thePlayer, command, id) id = tonumber(id) if id then if (id >= 401) and (id <= 611) then local posX, posY, posZ = getElementPosition(thePlayer) local createdVehicle = createVehicle(id, posX + 5, posY, posZ, 0, 0, 0, "Crossy") local vehicleName = getVehicleName(createdVehicle) warpPedIntoVehicle(thePlayer, createdVehicle) outputChatBox("Vehicle Created : "..vehicleName, thePlayer) else if (id <= 400) or (id >= 612) then outputChatBox("Incorrect ID : "..id, thePlayer) end end end end addCommandHandler("v", vehicle) I was just wondering if that's a good way for code to look like are other coders able to read that with no problems as I want my code as Cleanness and Readable as possible.
  10. Crossy101

    [Help]

    A lot of people don't like making only showing you the functions on how it can be done I'll just give you an example on how it could be done. getElementPosition() - Will get the players position getElementsByType() - Will check if the player is a player if true then getDistanceBetweenPoints3D() - Will check where both elements are and you can make it so that if either elements are withing 10m or 10 units of a player then stop them from aiming or shooting!! LUA is probably one of the most basic languages out there it also has a lot of tutorials online on how you can code with LUA. Good Luck!
  11. Well everybody start's somewhere right!
  12. An Example is pretty much the script though, just look around the MTA Functions and you will find some examples on how to use those functions within the AFK Script.
×
×
  • Create New...