Jump to content

GTX

Members
  • Posts

    1,273
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by GTX

  1. Put it inside your script. Like this: local donate = {} local allTimeDonate = {} local con = dbConnect("sqlite", "db/donate.db") dbExec(con, "CREATE TABLE IF NOT EXISTS donators (account TEXT, time TEXT)") function loadUsers(query) local data = dbPoll(query, 0) if (data) then for ind, d in ipairs(data) do allTimeDonate[d.account] = d.time if (d.account and getAccount(d.account) and getAccountPlayer(getAccount(d.account))) then donate[d.account] = tonumber(d.time) end end end end dbQuery(loadUsers, con, "SELECT * FROM donators") function isPlayerDonator(player) local account = getAccountName(getPlayerAccount(player)) return donate[account] end function addDonatorToDB(player, cmd, account, hours) if (not (hasObjectPermissionTo(player, "function.banPlayer", false))) then return end if (account and hours) then if (not getAccount(account)) then outputChatBox("No account with "..account.." as username", player, 2500, 0, 0) return end if (not tonumber(hours) or tonumber(hours) < 0) then outputChatBox(tostring(hours).." is an invalid hour specific", player, 2500, 0, 0) return end local plr = getAccountPlayer(getAccount(account)) if (not allTimeDonate[getAccount(account)]) then dbExec(con, "INSERT INTO donators (account, time) VALUES (?, ?)", tostring(account), tostring(hours)) donate[account] = tonumber(hours) if (tonumber(hours) == 0) then hours = "infinite" end outputDebugString(getPlayerName(player).. " added "..hours.." VIP hours to "..account) outputChatBox("Added "..hours.." VIP hours to "..account, player, 255, 150, 0) if (plr) then outputChatBox(getPlayerName(player).." added "..hours.." VIP hours to your account ("..account..")", plr, 0, 2500, 0) end end end end addCommandHandler("addvip", addDonatorToDB) function removeOfflineVIP(player, cmd, account) if (not (hasObjectPermissionTo(player, "function.kickPlayer", false))) then return end if (account) then if (not getAccount(account)) then outputChatBox("No account with "..account.." as username", player, 2500, 0, 0) return end if (donate[account]) then donate[account] = nil end if (allTimeDonate[account]) then allTimeDonate[account] = nil end dbExec(con, "DELETE FROM donators WHERE account=?", tostring(account)) outputDebugString(getPlayerName(player).. " removed account "..account.." from database") end end addCommandHandler("removevip", removeOfflineVIP) function makeDonateTick() for ind, d in pairs(donate) do if (ind and getAccount(ind)) then if (getAccountPlayer(getAccount(ind))) then if (donate[ind] and donate[ind] < 1 and donate[ind] ~= 0) then donate[ind] = nil allTimeDonate[ind] = nil dbExec(con, "DELETE FROM donators WHERE account=?", tostring(ind)) outputDebugString("Remove account "..ind.." from database because time ran out", root, 255, 255, 0) elseif (donate[ind] and donate[ind] > 1 and donate[ind] ~= 0) then donate[ind] = donate[ind] - 1 dbExec(con, "UPDATE donators SET time=? WHERE account=?", tostring(donate[ind]), tostring(ind)) outputDebugString("Account "..ind.." VIP Time set to "..donate[ind].." Hours") elseif (donate[ind]) then outputDebugString("Account "..ind.." has infinite VIP hours") end end end end end setTimer(makeDonateTick, 3600000 , 0) function getVipsTable(player) --if (exports.CEDadmin:doesPlayerHaveAccess(player, "viewVipGUI")) then if (not (hasObjectPermissionTo(player, "function.kickPlayer", false))) then return end triggerClientEvent(player, "donate.showDonateMembers", player, allTimeDonate) end addCommandHandler("showvip", getVipsTable) function donaterLoggedIn() dbQuery(loadUsers, con, "SELECT * FROM donators") end addEventHandler("onPlayerLogin", root, donaterLoggedIn) function getMyVIP(plr) if (not isPlayerDonator(plr)) then return end local hours = isPlayerDonator(plr) local minutes = math.floor(hours / 60) if (tonumber(hours) == 0) then hours = "infinite" minutes = "nil" end outputChatBox("You have "..hours.." VIP Hours ("..minutes.." minutes) remaining on this account ("..getAccountName(getPlayerAccount(plr))..")", plr, 0, 2500, 0) end addCommandHandler("VIP Hours", getMyVIP) function setCorrectVIPData() for ind, plr in pairs(getElementsByType("player")) do setElementData(plr, "VIP Hours", donate[getAccountName(getPlayerAccount(plr))]) end end setTimer(setCorrectVIPData, 1000, 0) function Converteviptocash (thePlayer) local acc = getPlayerAccount(thePlayer) if isGuestAccount(acc) then return end local accName = getAccountName(acc) dbExec(con, "UPDATE donators SET time=? WHERE account=?", tonumber(donate[accName])-1, accName) givePlayerMoney ( thePlayer, 10000 ) end addCommandHandler ( "Converteviptocash", Converteviptocash )
  2. function Converteviptocash (thePlayer) local acc = getPlayerAccount(thePlayer) if isGuestAccount(acc) then return end local accName = getAccountName(acc) dbExec(con, "UPDATE donators SET time=? WHERE account=?", tonumber(donate[accName])-1, accName) givePlayerMoney ( thePlayer, 10000 ) end addCommandHandler ( "Converteviptocash", Converteviptocash )
  3. The code I gave you. local hit, _, _, _, hitElement = processLineOfSight(x, y, z-dist, x, y, z-dist-offset, false, true, false, false, false) hitElement is the element under the hunter. attachElements(hitElement, HUNTER)
  4. Well, the code I gave you should work fine.
  5. I do not know, it should work fine, show full script.
  6. They should. function Converteviptocash (thePlayer) setElementData(thePlayer, "VIP Hours", (tonumber(getElementData(thePlayer, "VIP Hours")) or 0)-1) givePlayerMoney ( thePlayer, 10000 ) end addCommandHandler ( "Converteviptocash", Converteviptocash )
  7. function Converteviptocash (thePlayer) setElementData(thePlayer, "VIP Hours", getElementData(thePlayer, "VIP Hours")-1) givePlayerMoney ( thePlayer, 10000 ) end addCommandHandler ( "Converteviptocash", Converteviptocash )
  8. It doesn't work? Any errors in debugscript? At least tabulate your code. addEventHandler ("onPlayerWasted",getRootElement(), function(killer,weapon,bodypart) if killer then if getElementData (killer,"hacedm") then outputChatBox ("En zonas de DM las recompensas de Mercenario están canceladas.",killer) return end if getElementData (killer,"oficiomercenario") then if getPlayerMoney(source)<500 then setPlayerMoney (killer,getPlayerMoney(killer)+1000) outputChatBox ("¡Has matado a alguien y has recibido 1000$!",killer,255,0,0) return end local naombre = getPlayerName (source) setPlayerMoney (source,getPlayerMoney(source)-500) setPlayerMoney (killer,getPlayerMoney(killer)+1000) outputChatBox ("¡Has matado a alguien y has recibido 1000$!",killer,255,0,0) elseif getElementData (source,"oficiomercenario") then if getPlayerMoney (source)<2000 then setPlayerMoney (killer,getPlayerMoney(killer)+1000) return end setPlayerMoney (source,getPlayerMoney(source)-2000) setPlayerMoney (killer,getPlayerMoney(killer)+1000) end end end ) Give full code.
  9. GTX

    Some questions

    From my point of view: Pairs gives a general iterator over all the keys and values in the table, numerical or not, in no particular order, meanwhile ipairs goes over the array part, in order. Therefore pairs is faster.
  10. GTX

    Some questions

    You can use break to break a loop. for i=1, 10 do if i == 5 then break -- Breaks loop, doesn't go on. end end While is like a loop which repeats process until the condition is true. while true do end -- Or: local i = 1 while i <= 10 do i = i + 1 -- Goes until 10 end Until is used with repeat like: local i = 1 repeat -- Repeats step until desired value or true i = i + 1 until i == 10 -- Stops when it's 10
  11. GTX

    Armour Stat

    Nope, not really. Can be written under 30 lines of code.
  12. GTX

    Armour Stat

    This clearly isn't a joke. Armor has a special flag, but it's not listed there nor isn't in MTA's source code. I don't even think GTA has implemented max armor scaling while going through missions and whole game, that is why it does not exist. The only way would be to create custom armor system. Use onClientPedDamage, set element data to a ped as "armor" then decrease it each time he gets damaged (and cancel the event of course).
  13. GTX

    error

    You need isMouseInPosition function. function isMouseInPosition(a, b, c, d) if not isCursorShowing() then return end local x, y = getCursorPosition() x, y = x*sx, y*sy if x >= a and y >= b and x <= a+c and y <= b+d then return true end return false end
  14. It is same as regular MySQL. Contact me via PM if you want.
  15. Yes. Use DB functions.
  16. GTX

    little help here

    You can't set debugscript for a server since it's client command. Go into your server with your MTA client and then type this command.
  17. Via root access, if you don't have it, contact your host.
  18. MySQL module is pretty outdated, use DB functions. dbConnect dbQuery dbPoll dbFree If you really want to use old MySQL module: http://gtx.ultimateairgamers.com/cloud/ ... ient.so.15 - Goes into /usr/lib/
  19. GTX

    Armour Stat

    As wiki says: Things like infinite run, fire proof CJ, 150 health, 150 armor have special activation flags. They need a way to be triggered on/off. setPedStat
  20. GTX

    onStream load mods

    Why is it so bad if you load mods when player joins? If you don't like them to wait for load, do your own mod loading system with triggerLatentClientEvent, file functions and loadstring. They could move freely with some ping here and there but if you use triggerLatentClientEvent correctly, it's very good.
  21. GTX

    3d line

    Replace TXDs and DFFs engineLoadTXD engineImportTXD engineLoadDFF engineReplaceModel
  22. GTX

    Help

    LabiVila is right, it works that way also. But you could create edit, set alpha to 0 and then get the text in the edit you created with function guiGetText and "paste" it on the dxDrawText.
  23. GTX

    I have problem

    There are many other people that need help. You should open wiki and read, if you don't know how to use it. I can't support your laziness. function arr(key) if isElement(sevenShopList) then if key == "arrow_d" then if guiGridListGetSelectedItem(sevenShopList) == guiGridListGetRowCount(sevenShopList) then return end guiGridListSetSelectedItem(sevenShopList, guiGridListGetSelectedItem(sevenShopList)+1, 1) else if guiGridListGetSelectedItem(sevenShopList) == 0 then return end guiGridListSetVerticalScrollPosition(sevenShopList, guiGridListGetSelectedItem(sevenShopList)-1, 1) end end end bindKey("arrow_d", "down", arr) bindKey("arrow_u", "down", arr)
  24. You forgot to add music to meta: <file src="music/music.mp3"/> Should look like this: <meta> <info name="SpawnPanel" author="Shaman" description="None" version="1.0" type="script"></info> <script src="client.lua" type="client"></script> <script src="server.lua" type="server"></script> <file src="music/music.mp3"/> </meta> Server: function onlogin() triggerClientEvent(source, "showGUI", source) end addEventHandler("onPlayerLogin", getRootElement(), onlogin) function createAxisTeam () AxisTeam = createTeam ("Axis", 40, 40, 40) end addEventHandler ("onResourceStart", resourceRoot, createAxisTeam) function createUSATeam () USATeam = createTeam ("USA", 255, 255, 31) end addEventHandler ("onResourceStart", resourceRoot, createUSATeam) function joinTiger() setPlayerTeam(source,AxisTeam) setPlayerNametagColor ( source, 255, 200, 0 ) spawnPlayer (source, -2117.46, -2340.69, 30.2872810, 0,19, 0, 0) local x,y,z = getElementPosition(source) local vehicle = createVehicle(432,-2117.46, -2340.69, 30.2872810 + 3) warpPedIntoVehicle(source,vehicle) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("You have spawned with Tiger I Aufs E. tank!",source,0,200,0) end addEvent("spawn_tiger", true) addEventHandler("spawn_tiger",root,joinTiger) function joinSherman() setPlayerTeam(source,USATeam) setPlayerNametagColor ( source, 255, 200, 0 ) spawnPlayer (source, -2117.46, -2340.69, 30.2872810, 0,31, 0, 0) local x,y,z = getElementPosition(source) local vehicle = createVehicle(601,-2770.91, -2299.95, 4.52309 + 3) warpPedIntoVehicle(source,vehicle) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("You have spawned with M4 Sherman tank!",source,0,200,0) end addEvent("spawn_sherman", true) addEventHandler("spawn_sherman",root,joinSherman) function joinPershing() setPedSkin ( source, 33 ) local x,y,z = getElementPosition(source) local vehicle = createVehicle(455,-1067, -1207, 128.5 + 1) warpPedIntoVehicle(source,vehicle) outputChatBox("You have spawned with M26 Pershing tank!",source,0,200,0) end addEvent("spawn_pershing", true) addEventHandler("spawn_pershing",root,joinPershing) function joinTiger2() setPedSkin ( source, 12 ) local x,y,z = getElementPosition(source) local vehicle = createVehicle(450,-1067, -1207, 128.5 + 1) warpPedIntoVehicle(source,vehicle) outputChatBox("You have spawned with King Tiger II tank!",source,0,200,0) end addEvent("spawn_tiger2", true) addEventHandler("spawn_tiger2",root,joinTiger2) function onWasted(totalAmmo, killer, killerWeapon, bodypart, stealth) triggerClientEvent(source, "showGUI", source) end addEventHandler ("onPlayerWasted", getRootElement(), onWasted) function setCameraOnPlayerJoin () fadeCamera(source, true, 5) setCameraMatrix(source, -1231.6711, -273.84088, 22.8733, -1345.63241, -477.8543588, 12.8733) end addEventHandler("onPlayerJoin", getRootElement(), setCameraOnPlayerJoin) function setCameraOnPlayerWasted () fadeCamera(source, true, 5) setCameraMatrix(source, -1244.6711, -287.84088, 15.8733, -1345.63241, -477.8543588, 12.8733) end addEventHandler("onPlayerWasted", getRootElement(), setCameraOnPlayerWasted) function OnPlayerSpawn () showPlayerHudComponent("radar", true) end addEventHandler("onPlayerSpawn", getRootElement(), OnPlayerSpawn) -- Hide some of the hud components when a player joins the server addEventHandler ( "onPlayerWasted", root, function () setPlayerHudComponentVisible ( source, "ammo", false ) -- Hide the ammo displays for the newly joined player setPlayerHudComponentVisible ( source, "weapon", false ) -- Hide the weapon displays for the newly joined player end ) Client: classWnd = guiCreateWindow(185, 129, 479, 407, "Spawn Panel", false) guiWindowSetSizable(classWnd, false) guiSetVisible(classWnd, false) spawnG = guiCreateGridList(5, 27, 167, 160, false, classWnd) guiGridListAddColumn(spawnG, "Allies", 0.9) skins = { {"M4 Sherman", 287}, {"M26 Pershing (not available)", 171}, } for i,skins in ipairs(skins) do row = guiGridListAddRow(spawnG) guiGridListSetItemText(spawnG, row, 1, tostring(skins[1]), false, false) guiGridListSetItemData(spawnG, row, 1, tostring(skins[2])) end guiGridListAddRow(spawnG) spawnbtn = guiCreateButton(35, 200, 102, 44, "To battle!", false, classWnd) desc = guiCreateMemo(10, 260, 459, 140, "Welcome to World of Tanks MTA server! Choose your team!", false, classWnd) guiMemoSetReadOnly(desc, true) guiCreateLabel(166, 242, 136, 13, "Spawn Panel By Shaman", false, classWnd) function joinAllies() if ( source == spawnbtn ) then local row, col = guiGridListGetSelectedItem( spawnG ) local name = guiGridListGetItemText( spawnG, row, col ) if name == "M4 Sherman" then local id = 287 triggerServerEvent("spawn_sherman", getLocalPlayer(), id) guiSetVisible(classWnd, false) showCursor(false) elseif name == "M26 Pershing" then local id = 171 triggerServerEvent("spawn_pershing", getLocalPlayer(), id) guiSetVisible(classWnd, false) showCursor(false) end end end addEventHandler("onClientGUIClick",root,joinAllies) addEventHandler("onClientGUIClick",root,joinSurvivor) spawnG2 = guiCreateGridList(302, 27, 167, 160, false, classWnd) guiGridListAddColumn(spawnG2, "Axis", 0.9) skins = { {"Tiger I Ausf E", 270}, {"King Tiger II (not available)", 127}, } for i,skins in ipairs(skins) do row = guiGridListAddRow(spawnG2) guiGridListSetItemText(spawnG2, row, 1, tostring(skins[1]), false, false) guiGridListSetItemData(spawnG2, row, 1, tostring(skins[2])) end guiGridListAddRow(spawnG2) spawnbtn2 = guiCreateButton(330, 200, 102, 44, "To battle!", false, classWnd) function joinAxis() if ( source == spawnbtn2 ) then local row, col = guiGridListGetSelectedItem( spawnG2 ) local name = guiGridListGetItemText( spawnG2, row, col ) if name == "Tiger I Ausf E" then local id = 270 triggerServerEvent("spawn_tiger", getLocalPlayer(), id) guiSetVisible(classWnd, false) showCursor(false) elseif name == "King Tiger II" then local id = 127 triggerServerEvent("spawn_tiger2", getLocalPlayer(), id) guiSetVisible(classWnd, false) showCursor(false) end end end addEventHandler("onClientGUIClick",root,joinAxis) addEventHandler("onClientGUIClick",root,joinSwag) addEvent("showGUI", true) function guishow(player) guiSetVisible(classWnd, true) showCursor(true) end addEventHandler("showGUI",getRootElement(),guishow) --music local sound function startSound (killer, weapon, bodypart) sound = playSound("music/music.mp3") setSoundVolume(sound, 0.5) end addEventHandler("onClientPlayerWasted", getLocalPlayer(), startSound) function destroySound() if isElement(sound) then stopSound(sound) end end addEventHandler("onClientPlayerSpawn", getLocalPlayer(), destroySound) Tested, works fine.
×
×
  • Create New...