Jump to content

Ace_Gambit

Members
  • Posts

    569
  • Joined

  • Last visited

Everything posted by Ace_Gambit

  1. xmlNodeFindSubNode is not a function. This should be xmlFindSubNode.
  2. Ace_Gambit

    .

    What happened to Adriaan?
  3. You can not play custom sound files in DP2.
  4. Stupid question but is the helpmanager resource loaded?
  5. Ace_Gambit

    Stumped

    Here's your code without error messages http://pastebin.com/mf34e5f2. There are however still warning message that I will explain. But first a list of changes to the original source. 1) I've removed all semi columns in your code header. This is not wrong but my advice is to do this everywhere or leave it out. 2) Changed the following code: tbl[player][logged] = 1 tbl[player] = {} tbl[player][logged] = 1 3) The follwing code was moved to a global point instead of inside the function (caused warnings otherwise): pcomp = createColSphere(-2066.0, -859.0, 33.0, 4) hithq = createColSphere(-2002.0, -1019.0, 33.0, 4) adcomp = createColSphere(-1972.0, -1019.0, 33.0, 4) This leaves only 6 warning left but no more errors. The warnings are thrown by the following lines: local theCiv = createTeam(Civilian, 255, 255, 255) local theSFPD = createTeam(SFPD, 255, 255, 255) local theFBI = createTeam(FBI, 255, 255, 255) local theOrg = createTeam(Organisation, 255, 255, 255) This is because Civilian, SFPD, FBI and Organisation are not defined anywhere in the code you posted. setTimer(arrestTime, 1000, 0) The first parameter is a non existing function handle.
  6. Apart from that, having a private forum is never a good idea if you want people to join your community. They should at least be able to view the forum content before joining.
  7. This means that when a player is firing a rocket at the tank it will receive damage once (from that particular rocket). And damage caused by an explosion is synchronized meaning that you do not need an explicit server side call to set the tanks' health. EDIT: So basically this is all the code you need to provide very basic support for controlled tank damage. Client EFFECTIVE_RANGE = 10 EXPLOSION_DAMAGE = 5 BULLET_DAMAGE = 10 function onClientExplosion(x, y, z, type) local tX, tY, tZ = 0, 0, 0 local distance3D = 0 local health = 0 local damage = 0 for _, vehicle in ipairs((getElementsByType("vehicle", getRootElement()) or {})) do if (getVehicleID(vehicle) == 432) then tX, tY, tZ = getElementPosition(vehicle) health = getElementHealth(vehicle) or 0 distance3D = getDistanceBetweenPoints3D(x, y, z, tX, tY, tZ) or 0 if (distance3D < EFFECTIVE_RANGE) then damage = EXPLOSION_DAMAGE * (EFFECTIVE_RANGE - distance3D) if (health - damage > 0) then setElementHealth(vehicle, health - damage) end end end end end function onClientPlayerWeaponFire(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) local health = 0 if (isElement(hitElement)) then if (getElementType(hitElement) == "vehicle") then if (getVehicleID(hitElement) == 432) then health = getElementHealth(hitElement) or 0 if (health - BULLET_DAMAGE > 0) then setElementHealth(hitElement, health - BULLET_DAMAGE) end end end end end addEventHandler("onClientExplosion", getRootElement(), onClientExplosion, true) addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFire, false) Server DAMAGE_LOSS = 5 function onVehicleDamage(loss) local health = 0 if (isElement(source)) then health = getElementHealth(source) or 0 if (health - DAMAGE_LOSS > 0) then setElementHealth(hitElement, health - DAMAGE_LOSS) end end end addEventHandler("onVehicleDamage", getRootElement(), onVehicleDamage, true)
  8. Forget what I said earlier. This code might actually work since the onClientExplosion event seems to trigger for the creators' view port only and setElementHealth is synchronized for both client and server code. EDIT: I did some testing (with 2 computers) and the damage factor is applied only once because the explosion event is not triggered when the creator is not the local player (or at least initiator).
  9. Yes, that is kind of an issue with this code. But I'll put my thinking hat on and see what I can do to make this work for all clients.
  10. Here's a simple alternative to make a rhino receive damage from explosions. EFFECTIVE_RANGE = 10 EXPLOSION_DAMAGE = 5 function onClientExplosion(x, y, z, type) local tX, tY, tZ = 0, 0, 0 local distance3D = 0 local health = 0 local damage = 0 for _, vehicle in ipairs((getElementsByType("vehicle", getRootElement()) or {})) do if (getVehicleID(vehicle) == 432) then tX, tY, tZ = getElementPosition(vehicle) health = getElementHealth(vehicle) or 0 distance3D = getDistanceBetweenPoints3D(x, y, z, tX, tY, tZ) or 0 if (distance3D < EFFECTIVE_RANGE) then damage = EXPLOSION_DAMAGE * (EFFECTIVE_RANGE - distance3D) if (health - damage > 0) then setElementHealth(vehicle, health - damage) end end end end end addEventHandler("onClientExplosion", getRootElement(), onClientExplosion, true)
  11. Ace_Gambit

    Serial number problems

    Thanks. It works like a charm now.
  12. Ace_Gambit

    Serial number problems

    I can't get it to work. It freezes at the loading screen.
  13. setAccountData works for the duration of a session. All data will be lost when you close the server.
  14. Keep in mind that getElementsWithinColShape does not work in DP2.
  15. function slashMe(commandName, action) local x, y, z = 0, 0, 0 local x2, y2, z2 = 0, 0, 0 if(action ~= "" and action)then x, y, z = getElementPosition(source) or 0, 0, 0 for _, player in ipairs((getElementsByType("player") or {})) do x2, y2, z2 = getElementPosition(player) or 0, 0, 0 if ((getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) or 0) <= 5) then outputChatBox("* " .. (getClientName(source) or "") .. " " .. action, player, 255, 0, 255) end end else outputChatBox("USE: /me [action]", source, 255, 255, 0) end end
  16. Account data is stored server side. Clients can not access the files that contain account data.
  17. In MTA players are elements (elements of type "player" to be exact). You can get a table of element types with the getElementsByType function. players = getElementsByType("player") for key, value in ipairs(players) do -- end
  18. Yes, this is true for DP2. The account data is erased when the server shuts down. It is supposedly solved in DP3 so my advice is to keep the script because it should work in the next release.
  19. You could try a modified version of the code posted earlier. local loginAttempts = {} function SubmitLogin(thePlayer, userPass) local totalAttempts = loginAttempts[thePlayer] or false local account = false local pass = "" local name = "" local ip = "" if (not hasObjectPermissionTo(getThisResource(), "function.getClientIP") or not hasObjectPermissionTo(getThisResource(), "function.banIP")) then outputDebugString("ACL denied access to functions.") return false end if (isElement(thePlayer) and totalAttempts) then account = getClientAccount(thePlayer) if (account) then pass = getAccountData(account, "Player.pass") if (userPass == pass) then triggerClientEvent(source, "onServerLoginSuccess", getRootElement()) else loginAttempts[thePlayer] = totalAttempts + 1 if (totalAttempts < 5) then triggerClientEvent(source, "onServerLoginFailed", getRootElement()) outputChatBox("That log-in information is incorrect. Please try again (" .. totalAttempts .. " attempt(s)).", thePlayer, 255, 0, 0, false) else name = getClientName(thePlayer) or "" ip = getClientIP(thePlayer) or "" banIP(ip) outputChatBox("#FF0000" .. name .. " has been auto-banned. Reason: 5 Failed log-in attempts.", getRootElement(), 255, 255, 255, true) end end end end return true end function onPlayerJoin() loginAttempts[source] = 0 end function onPlayerQuit(reason) loginAttempts[source] = nil end addEventHandler("onPlayerJoin", root, oPlayerJoin, true) addEventHandler("onPlayerQuit", root, onPlayerQuit, true)
  20. I never knew that. Is that since 2.1, because I get people trying to connect to my local server all the time? And I didn't register it anywhere.
  21. Personally I prefer creating classes inside the resource and keep all functionality that is directly related to the script in one package instead of using many separate resources. Regarding data storage, it is up to the developers to make sure their storage method does not interrupt with other resources. The aim is to create a script that does not bother end-users with the storage method or other complex tasks.
  22. Here's a simple example showing how to make sure a global server side variable is not overwritten when a new client is accessing the value. local players = {} function SubmitLogin(thePlayer) local data = players[thePlayer] or false local account = false if (isElement(thePlayer) and data) then account = getClientAccount(thePlayer) [..] players[thePlayer] = data + 1 [..] end end function onPlayerJoin() players[source] = 0 end function onPlayerQuit(reason) players[source] = nil end addEventHandler("onPlayerJoin", root, oPlayerJoin, true) addEventHandler("onPlayerQuit", root, onPlayerQuit, true)
  23. No problem. I'm working on a SMTP module to allow basic in-game e-mail services.
  24. I've noticed a lot of spam in the MTA forums by particular users. Can't you guys block the entire subnet of those accounts because they are probably one and the same person? And these spam replies pollute my "new posts" list. memberlist.php?mode=viewprofile&u=31922 memberlist.php?mode=viewprofile&u=31832 memberlist.php?mode=viewprofile&u=31846 memberlist.php?mode=viewprofile&u=31819 To name just a few of those retards ^. EDIT: And some more to add to the list . memberlist.php?mode=viewprofile&u=31846 memberlist.php?mode=viewprofile&u=31870 memberlist.php?mode=viewprofile&u=32043
×
×
  • Create New...