Jump to content

Castillo

Retired Staff
  • Posts

    21,935
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Castillo

  1. You have to create it yourself. Edit: There's a resource called "msgbox" which does this if I'm right, the resource comes with MTA:
  2. addEventHandler("onPlayerJoin",source,spawnSumoPlayer) Change 'source' to 'root' and remove 'source' from function name, it's already defined by itself. Also, this makes no sense: spawnPoints = { [1]=true, [2]=true, } spawnPlayer(source,spawnPoints[math.random (1,2)]) You are giving spawnPlayer a boolean ( true ).
  3. Usa el evento onClientPlayerWeaponSwitch y guiStaticImageLoadImage.
  4. Castillo

    Colour code

    Replace whole "client.lua" with this one: --- -- Main client file with drawing and calculating. -- -- @author driver2 -- @copyright 2009-2010 driver2 -- -- Recent changes: -- 2010-02-09: Made GUI-key a setting in defaultSettings.lua, added help to radio buttons, replaced "infocenter" with "gamecenter" ------------------------- -- Initialize Settings -- ------------------------- local gamecenterResource = false settingsObject = Settings:new(defaultSettings,"settings.xml") local function s(setting,settingType) return settingsObject:get(setting,settingType) end ----------------------------- -- Variables and Constants -- ----------------------------- fonts = {"default","default-bold","clear","arial","sans","pricedown","bankgothic","diploma","beckett"} local screenWidth,screenHeight = guiGetScreenSize() local x = nil local y = nil local x2 = nil local y2 = nil local h = nil local readyToDraw = false local mapLoaded = false local screenFadedOut = false local updateIntervall = 1000 local g_CheckpointDistance = {} local g_CheckpointDistanceSum = {} local g_players = {} local g_TotalDistance = 0 local g_recordedDistances = {} local g_recordedDistancesForReplay = {} local g_times = {} ------------ -- Events -- ------------ function initiate() settingsObject:loadFromXml() mapStarted() sendMessageToServer("loaded") end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),initiate) function mapStarted() -- Start under the assumption that no checkpoints are found, -- so not ready to draw (also the new data hasn't been loaded -- yet) readyToDraw = false mapLoaded = false if loadMap() then -- If data was successfully loaded, prepare drawing mapLoaded = true calculateCheckpointDistance() prepareDraw() end g_times = {} g_delay = {} -- TODO: load distances for map g_recordedDistancesForReplay = g_recordedDistances g_recordedDistances = {} g_replayCount = 0 end addEventHandler("onClientMapStarting",getRootElement(),mapStarted) ------------------------------- -- Load and prepare map data -- ------------------------------- function loadMap() --local res = call(getResourceFromName("mapmanager"),"getRunningGamemodeMap") -- Get the data or empty tables, if none of these elements exist g_Spawnpoints = getAll("spawnpoint") g_Checkpoints = getAll("checkpoint") if #g_Spawnpoints > 0 and #g_Checkpoints > 0 then return true end return false end function getAll(name) local result = {} for i,element in ipairs(getElementsByType(name)) do result[i] = {} result[i].id = getElementID(element) or i local position = { tonumber(getElementData(element,"posX")), tonumber(getElementData(element,"posY")), tonumber(getElementData(element,"posZ")) } result[i].position = position; end return result end function calculateCheckpointDistance() local total = 0 local cps = {} local cpsSum = {} local pos = g_Spawnpoints[1].position local prevX, prevY, prevZ = pos[1],pos[2],pos[3] for k,v in ipairs(g_Checkpoints) do local pos = v.position if prevX ~= nil then local distance = getDistanceBetweenPoints3D(pos[1],pos[2],pos[3],prevX,prevY,prevZ) total = total + distance cps[k] = distance cpsSum[k] = total end prevX = pos[1] prevY = pos[2] prevZ = pos[3] end g_CheckpointDistance = cps g_CheckpointDistanceSum = cpsSum g_TotalDistance = total end ----------- -- Times -- ----------- -- SHOULD BE DONE: maybe reset data if player rejoins? maybe check if he already passed that checkpoint --[[ -- Adds the given time for the player at that checkpoint to the table, -- as well as displays it, if there is a time at the same checkpoint -- to compare it with. -- -- @param player player: The player element -- @param int checkpoint: The checkpoint number -- @param int time: The number of milliseconds -- @return boolean false if parameters are invalid -- ]] function addTime(player,checkpoint,time) if player == nil then return false end if g_times[player] == nil then g_times[player] = {} end g_times[player][checkpoint] = time if player == getLocalPlayer() then -- For players who passed the checkpoint you hit before you for k,v in ipairs(getElementsByType("player")) do local prevTime = getTime(v,checkpoint) --var_dump("prevTime",prevTime) if prevTime then local diff = time - prevTime g_delay[v] = {diff,getTickCount()} end end else -- For players who hit a checkpoint you already passed local prevTime = getTime(getLocalPlayer(),checkpoint) if prevTime then local diff = -(time - prevTime) g_delay[player] = {diff,getTickCount()} end end end --[[ -- Gets the time of a player for a certain checkpoint, if it exists -- and the player has already reached it (as far as race is concerned) -- -- @param player player: The player element -- @param int checkpoint: The checkpoint number -- @return mixed The number of milliseconds passed for this player -- at this checkpoint, or false if it doesn't exist -- ]] function getTime(player,checkpoint) -- Check if the desired time exists if g_times[player] ~= nil and g_times[player][checkpoint] ~= nil then -- Check if player has already reached that checkpoint. This prevents -- two scenarios from causing wrong times to appear: -- 1. When a player is set back to a previous checkpoint when he dies twice -- 2. When a player rejoins and the player element remains the same (with the times still being saved -- at the other clients) local playerHeadingForCp = getElementData(player,"race.checkpoint") if type(playerHeadingForCp) == "number" and playerHeadingForCp > checkpoint then return g_times[player][checkpoint] end end return false end --[[ -- Calculates minutes and seconds from milliseconds -- and formats the output in the form xx:xx.xx -- -- Also supports negative numbers, to which it will add a minus-sign (-) -- before the output, a plus-sign (+) otherwise. -- -- @param int milliseconds: The number of milliseconds you wish to format -- @return string The formated string or an empty string if no parameter was specified -- ]] function formatTime(milliseconds) if milliseconds == nil then return "" end local prefix = "+" if milliseconds < 0 then prefix = "-" milliseconds = -(milliseconds) end local minutes = math.floor(milliseconds / 1000 / 60) local milliseconds = milliseconds % (1000 * 60) local seconds = math.floor(milliseconds / 1000) local milliseconds = milliseconds % 1000 return string.format(prefix.."%i:%02i.%03i",minutes,seconds,milliseconds) end ------------------- -- Communication -- ------------------- function serverMessage(message,parameter) if message == "update" then addTime(parameter[1],parameter[2],parameter[3]) end if message == "times" then g_times = parameter end end addEvent("onClientRaceProgressServerMessage",true) addEventHandler("onClientRaceProgressServerMessage",getRootElement(),serverMessage) function sendMessageToServer(message,parameter) triggerServerEvent("onRaceProgressClientMessage",getRootElement(),message,parameter) end
  5. Castillo

    Colour code

    That doesn't make any sense, it should work. Maybe something else in the script is messing it up.
  6. Use the exported functions "isGangSubLeader" and "getGangLeader".
  7. Castillo

    Colour code

    local players = {} for k,player in ipairs(getElementsByType("player")) do if not getElementData(player,"race.finished") then local headingForCp = getElementData(player,"race.checkpoint") local distanceToCp = distanceFromPlayerToCheckpoint(player,headingForCp) if distanceToCp ~= false then local name = getPlayerName(player):gsub ( "#%x%x%x%x%x%x", "" ) outputChatBox ( "ADDING: ".. tostring ( name ) ) table.insert(players,{name,calculateDistance(headingForCp,distanceToCp),player}) end end end Put that and tell me what does it output to chatbox.
  8. What was the problem?
  9. @3B00DG4MER: Any error coming from the server side script? is it added to the meta.xml?
  10. What do you mean by "won't add"?
  11. createTeam ( "Official Squad", 0, 0, 255 ) function aceptarr ( ) if ( getElementData ( source, "gang" ) == "GangNameHere" ) then -- Change this line. local theTeam = getTeamFromName ( "Official Squad" ) if ( theTeam ) then setPlayerTeam ( source, theTeam ) setPlayerNametagColor ( source, 0, 0, 255 ) setElementModel ( source, 285 ) giveWeapon ( source, 31, 550 ) giveWeapon ( source, 23, 550 ) giveWeapon ( source, 3, 550 ) giveWeapon ( source, 29, 550 ) giveWeapon ( source, 46, 550 ) giveWeapon ( source, 41, 5000 ) giveWeapon ( source, 34, 550 ) end end end addEvent ( "onGreeting", true ) addEventHandler ( "onGreeting", root, aceptarr )
  12. Castillo

    [Help]Blips

    What has that to do with ACL? Also, your code is wrong, it makes no sense.
  13. Castillo

    [Help]Blips

    You can use the function setElementVisibleTo
  14. You don't have any weapons when join the server, I don't see why you need this?
  15. takeAllWeapons is server side only. The second code has two problems: 1: Instead of getRootElement, it should be source. 2: The event handler must go after you defined the function. function relvadnahhuj ( ) takeAllWeapons ( source ) end addEventHandler ( "onPlayerJoin", getRootElement(), relvadnahhuj )
  16. This can be closed I guess: http://bugs.mtasa.com/view.php?id=6036
  17. Are you sure the model/position/radius are correct?
  18. Any errors in debugscript?
  19. Castillo

    [HELP] Bans

    It could be a bug in the script, open the debugscript ( /debugscript 3 ) and see if anything comes up when you click the details button.
  20. local playerWeapons = { } function spawn () if ( getElementData ( source, "Group" ) == "TMZ" ) then if ( not isGuestAccount ( getPlayerAccount ( source ) ) ) then if ( not playerWeapons [ source ] ) then playerWeapons [ source ] = { } end for slot = 0, 12 do local weapon = getPedWeapon ( source, slot ) if ( weapon > 0 ) then local ammo = getPedTotalAmmo ( source, slot ) if ( ammo > 0 ) then playerWeapons [ source ] [ weapon ] = ammo end end end setTimer ( spawnPlayer, 5600, 1, source, 2296.646484375, 556.4404296875, 11.618446350098 ) end end end addEventHandler ( "onPlayerWasted", getRootElement( ), spawn )
  21. local xml = getResourceConfig ( "skins.xml" ) for _, v in ipairs ( xmlNodeGetChildren ( xml ) ) do local row = guiGridListAddRow ( GUIEditor.gridlist[1] ) local model = xmlNodeGetAttribute ( v, "id" ) guiGridListSetItemText ( GUIEditor.gridlist[1], row, skins, tostring ( model ), false, false ) end By the way: "skins" is the column index, right?
  22. Your saving code is a mess, you are respawning the player as many times as weapons the player has.
  23. This is a common problem, it also happens with scroll panes ( check map editor ).
×
×
  • Create New...