Jump to content

Aibo

Retired Staff
  • Posts

    1,105
  • Joined

  • Last visited

Everything posted by Aibo

  1. Aibo

    [help] error

    teamSurvivor = createTeam ( "Survivors", 0, 255, 0 ) teamzombie = createTeam ( "Zombies", 255, 0, 0 ) g_Root = getRootElement() local g_TimeLimit,g_MissionTimer local mapTimers = {} local announcementText local defaults = { timeLimit = 300, } local function sortingfunction (a,b) return (getElementData(a,"Score") or 0) > (getElementData(b,"Score") or 0) end function zmMapStart(resource,mapRoot) local resourceName = getResourceName ( resource ) g_TimeLimit = (tonumber(get(resourceName..".time_limit")) and math.floor(tonumber(get(resourceName..".time_limit"))) or defaults.timeLimit)*1000 g_MissionTimer = exports.missiontimer:createMissionTimer (g_TimeLimit,true,true,0.5,20,true,"default-bold",1) addEventHandler("onMissionTimerElapsed", g_MissionTimer, onTimeElapsed) end addEventHandler("onGamemodeMapStart", g_Root, zmMapStart) addEventHandler ( "onPlayerJoin", g_Root, function() if announcementText then announcementText:sync(source) end end) function Endgame(winner,draw) for i,timer in ipairs(mapTimers) do if isTimer ( timer ) then killTimer ( timer ) end end outputChatBox ( "debug; 2;" ) mapTimers = {} destroyElement(g_MissionTimer) setTimer ( reboot, 6100, 1 ) if not winner then if draw then for i,player in ipairs(getElementsByType("player")) do -- add ( ) toggleAllControls(player,true,true,false) fadeCamera(player,false,10,0,0,0) end outputChatBox ( "debug; 3;" ) triggerClientEvent ( "onzombiewin", getRootElement()) outputChatBox("Выживших не осталось. Зомби победили!") announcementText:visible(true) announcementText:text("Выживших не осталось. Зомби победили!") announcementText:color(255,255,255,255) announcementText:sync() return else return end end outputChatBox ( "debug; 4;" ) for i,player in ipairs(getElementsByType("player")) do if Survivors ~= winner then -- what is survivors now? setCameraTarget(player,winner) -- winner is TEAM toggleAllControls(player,true,true,false) end fadeCamera(player,false,10,0,0,0) end outputChatBox ( "debug; 5;" ) triggerClientEvent ( "onsurwin", getRootElement()) outputChatBox("Выжившие победили! Они пережили нападение") announcementText:visible(true) announcementText:text(getTeamName(winner).." - Выжившие победили! Они пережили нападение") announcementText:color(getTeamColor(winner)) announcementText:sync() outputChatBox ( "debug; wintext;" ) end function reboot() announcementText:visible(false) announcementText:sync() exports.mapmanager:changeGamemode( getResourceFromName('zombie_mod') ) end function onTimeElapsed() local teamSurvivor = getElementsByType("team") -- you were getting same teams in both tables table.sort(teamSurvivor, sortingfunction) -- sortingFunction i suppose if getElementData ( teamSurvivor[1], "Score" ) == getElementData ( teamSurvivor[2], "Score" ) then Endgame(false, true) -- your "draw" return end if getTeamName(teamSurvivor[1]) == "Zombies" then Endgame(false,false) -- Zombies have the Score, sending no winner else Endgame(teamSurvivor[1],false) -- send the Survivors to Endgame() function end end
  2. addEvent( "onPlayerPickUpRacePickup", true ) function onPlayerPickUpRacePickup(pickupID,pickupType,vehicleModel) if pickupType == "vehiclechange" and vehicleModel == 425 then outputChatBox(getPlayerName(source).." got the hunter!") outputChatBox("#38ff06Disabling Ghostmode in 10 seconds...") setTimer(gmoff, 10000, 1) g_SToptimesManager:playerFinished( source, exports.race:getTimePassed()) -- gmoff() -- you already have a timer for this end end addEventHandler( "onPlayerPickUpRacePickup", getRootElement(), onPlayerPickUpRacePickup)
  3. you're not passing any arguments to server event, so playerName is nil. use source, it is the player element which triggered the event.
  4. use addEvent, addEventHandler on server side and triggerServerEvent in the client
  5. it makes perfect sense: xmlLoadFile returns root node. if you delete the root node, how can you operate the loaded XML file? just delete the file and that's it. maybe. EDIT: on the other hand, maybe you are trying to delete the file. anyway, i'd just delete all children of the root node.
  6. maybe you just can't destroy root node, that's all. try deleting all children.
  7. Aibo

    [help] error

    if player ~= winner then -- fix winner is team here.
  8. Aibo

    [help] error

    have you fixed anything i've posted? i dont know how you want to determine the winner, from what i can see you're trying to sort teams by points. well for the team with most points to be a winner: function onTimeElapsed() local teamSurvivor = getElementsByType("team") -- you were getting same teams in both tables table.sort ( teamSurvivor, sortingFunction ) -- sortingFunction i suppose if getElementData ( teamSurvivor[1], "Score" ) == getElementData ( teamSurvivor[2], "Score" ) then Endgame(false, true) -- your "draw" return end Endgame(teamSurvivor[1],false) -- send the team with most points to Endgame() function end
  9. Aibo

    [RP] Chatbox

    again: eh what? PS: try using google translator.
  10. local playerData = {} function getPlayerVehicle (player) if playerData[player] then return playerData[player].vehicle -- maybe you can just return this, but dunno if it triggers error else return nil end end function createPlayerData (player) if playerData[player] then return end playerData[player] = {} end function destroyVehicle (player) if playerData[player] then if playerData[player].vehicle then destroyElement (playerData[player].vehicle) playerData[player].vehicle = nil else return false end else createPlayerData(player) end end addEvent ("carBuy", true) addEventHandler ("carBuy", getRootElement(), function(id2, cost2, name2,x, y, z, sRz, thePlayer) if (getPlayerMoney (source) >= tonumber(cost2)) then outputChatBox ("Achat de " .. name2, source, 255, 0, 0, false) outputChatBox ("Prix: " .. cost2, source, 255, 0, 0, false) takePlayerMoney (source, tonumber (cost2)) local x,y,z = getElementPosition (source) -- local vehicle = createVehicle (id2, x, y, z, 0, 0, sRz ) destroyVehicle(source) playerData[source].vehicle = createVehicle (id2, x, y, z, 0, 0, sRz ) warpPedIntoVehicle(source, playerData[source].vehicle) local blii = createBlipAttachedTo ( playerData[source].vehicle, 56, source ) setElementVisibleTo ( blii, getRootElement ( ), false ) setElementVisibleTo ( blii, source, true ) else outputChatBox ("Vous ne pouvez acheter ce produit [pas assez d'argent]", source, 255, 0, 0, false) end end) PS: thePlayer doesnt exist there too (oops, maybe it is, but then what's the "source" for?).
  11. as i recall, you can't store elements in element data
  12. edit this script to add a vehicle owner/creator to a vehicle using setElementData(). and onPlayerQuit/onPlayerWasted/buying another vehicle check vehicles and destroy the ones created by player. or add a vehicle table and put vehicle elements there using player's name as a key, for example.
  13. Aibo

    [help] error

    line 58: for i,player in ipairs(getElementsByType"player") do again no parentheses line 59: if team ~= winner then where's team? line 60: setCameraTarget(player,winner) idk if you even can set camera target to a team, because here "winner" is supposed to be a team line 84: function isTimer ( timer ) MTA already has built-in function isTimer PS: if you know what you want to do, it doesnt mean you know what you're doing. for someone who uses OOP in Lua you're making a lot of errors.
  14. Aibo

    [help] error

    announcementText is not a function, it's an object this is nonsense: getElementsByType"team" you forgot the parentheses getElementData() takes only one element. whole onTimeElapsed() function is almost random code. what is sortingfunction? and indentation is horrible. and it looks like you dont really know what you're doing
  15. you can simply setElementData for the house marker with id or whatever.
  16. local rootElement = getRootElement() local screenWidth,screenHeight = guiGetScreenSize() local frame = {} frame[1] = "pic/01.png" frame[2] = "pic/02.png" frame[3] = "pic/03.png" frame[4] = "pic/04.png" frame[5] = "pic/05.png" frame[6] = "pic/06.png" frame[7] = "pic/07.png" frame[8] = "pic/08.png" frame[9] = "pic/09.png" frame[10] = "pic/10.png" frame[11] = "pic/11.png" frame[12] = "pic/12.png" frame[13] = "pic/13.png" frame[14] = "pic/14.png" frame[15] = "pic/15.png" frame[16] = "pic/16.png" frame[17] = "pic/17.png" frame[18] = "pic/18.png" frame[19] = "pic/19.png" frame[20] = "pic/20.png" frame[21] = "pic/21.png" frame[22] = "pic/22.png" frame[23] = "pic/23.png" frame[24] = "pic/24.png" frame[25] = "pic/25.png" frame[26] = "pic/26.png" frame[27] = "pic/27.png" frame[28] = "pic/28.png" frame[29] = "pic/29.png" frame[30] = "pic/30.png" frame[31] = "pic/31.png" frame[32] = "pic/32.png" frame[33] = "pic/33.png" frame[34] = "pic/34.png" frame[35] = "pic/35.png" frame[36] = "pic/36.png" frame[37] = "pic/37.png" frame[38] = "pic/38.png" frame[39] = "pic/39.png" frame[40] = "pic/40.png" frame[41] = "pic/41.png" frame[42] = "pic/42.png" frame[43] = "pic/43.png" frame[44] = "pic/44.png" frame[45] = "pic/45.png" frame[46] = "pic/46.png" frame[47] = "pic/47.png" frame[48] = "pic/48.png" frame[49] = "pic/49.png" frame[50] = "pic/50.png" frame[51] = "pic/51.png" frame[52] = "pic/52.png" frame[53] = "pic/53.png" function randomframe() dxDrawImage(0, 0, screenWidth, screenHeight, frame[math.random(#frame)]) end addEventHandler("onClientRender",rootElement, randomframe)
  17. have you edited the «play» resource?
  18. calculate rotation from 2 getCameraMatrix() XY points, and setPedRotation() with that angle?
  19. if i'd have to choose, i'd give you a read-only for some time for the following reasons: 1. your english is hard to understand. even google translator can do better 2. you create a lot of topics with very basic questions 3. you don't like the answers you get 4. have i mentioned bad english? oh, if you mean «if i had to choose how to fill up 500MB of resources» — i wouldn't. it's stupid, it's unnecessary, it's just plain wrong. and it won't have any difference, cause you won't have 500MB of Lua code, but probably some music and stuff. i think it doesn't matter to which folder clients have to download media files to.
  20. 1. using so many events is a bit redundant (1 event to create and hide, next event to show?). just create and hide windows on resource start, or use the same 1 event to create and show. 2. you're triggering client event for all players, not the one that needs it. use: triggerClientEvent(source,"ShowLogin",getRootElement()) 3. use "/debugscript 3" in game to see client-side script errors.
  21. if you'll use 500MB of resources on your server, it will make no difference for you, whether it's separated to «rescources folders» or in one big ass resource. 'cause noone will download that load of :~. this topic is called «rescource problem», and there were no problems discussed whatsoever (and it's hardly related to scripting itself). so please either move on to the problem you're having (and «what if my has 500MB rescource only admins know better» isnt one) and make some sense, or i'll lock this one.
  22. idk what this has to do with hex, but: http://lua-users.org/wiki/MathLibraryTutorial
  23. or add it to mtaserver.conf for autostart: <resource src="yourResourceName" startup="1" protected="0" />
×
×
  • Create New...