Franc[e]sco

Members
  • Content Count

    40
  • Joined

  • Last visited

Community Reputation

0 Neutral

1 Follower

About Franc[e]sco

  • Rank
    Rat

Details

  • Gang
    UG

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Text Utilities 1.0 I recently re-started messing around with lua and made this little library with handy text functions. I didn't upload this to the resource center because it's not a resource and it can't be used as a resource because it gets too messy with callback functions and other stuff. You have to put the source file into your resource. I am currently accepting suggestions on more useful functions, so please post all your ideas! --> Download <-- What is it? Text Utilities is a library that simplifies MTA Text functions for the most common tasks. How do I use it? - Download it - Put text_utilities.lua in your resource zip file - Add this to meta.xml <script src="text_utilities.lua" /> Things you must know before using it: - The arguments between square brackets [ ] are OPTIONAL and you can omit them when calling the function. When omitted, optional arguments will assume their default value - The functions outputTimedText and outputCountdown use named arguments because I like them with functions that have lots of arguments. Basically, to call a function you can just do function{arg1=value, anotherargument=anothervalue} and the argument order doesn't matter. - This library is server-sided! You can only call its functions from the server-side (unless you use triggerServerEvent) Function List: outputTimedText display, textitem outputTimedText{ player, timeout, text, [x=0.5, y=0.5, priority="high", r=255, g=255, b=255, a=255, size=3.0, alignX="center", alignY="center", shadow_alpha=100, callback=nil] } Displays a text for a set amount of time for a player Required Arguments: - player: The player who will see the text - timeout: Duration (in milliseconds) of the text. Must be over 50 ms - text: Text string that will be displayed Optional Arguments: - x: A floating point number between 0.0 and 1.0 indicating how far across the screen the text should be shown, as a percentage of the width, from the left hand side. - y: A floating point number between 0.0 and 1.0 indicating how far down the screen the text should be shown, as a percentage of the height, from the top. - priority: How important it is that this text should be up to date on client's screens. Valid values are: "low", "medium", "high". - r, g, b: Values between 0 and 255 indicating how red/green/blue the text should be. - a: A value between 0 and 255 indicating how transparent the text should be, with 0 being fully transparent, and 255 being opaque. - size: A floating point value indicating the scale of the text. The default is 1.0, which is around 12pt. - alignX: A string representing the X-alignment of the text. ("left", "center", "right") - alignY: A string representing the Y-alignment of the text. ("top", "center", "bottom") - shadow_alpha: A value between 0 and 255 indicating how dark the drop shadow should be. - callback: The function that will be called once the text runs out Return Values: - The text display - The text item Examples: -- Example 1 -- Command that lets the player display some text on his screen -- format: /showtext text timeout addCommandHandler("showtext", function(source, cmdname, txt, delay) outputTimedText{ player = source, text = txt, timeout = tonumber(delay) } end ) -- Example 2 -- Using the callback function to freeze the player only until the text runs out -- Format: /freezeme milliseconds addCommandHandler("freezeme", function(source, cmdname, delay) setPedFrozen(source, true) outputTimedText{ player = source, text = "You are frozen for " .. delay .. " milliseconds", timeout = tonumber(delay), callback = function () setPedFrozen(source, false) end } end ) destroyPlayerTimedText destroyPlayerTimedText(player) Makes a text disappear if it hasn't already ran out. Required Arguments: - player: the player who owns the text Example: -- Example 3 -- Using destroyPlayerTimedText to avoid multiple overlapped text elements addCommandHandler("spam", function(source) local spamcount = 0 setTimer( function () destroyPlayerTimedText(source) local display, text = outputTimedText{ player = source, timeout = 5000, text = "Spam" .. spamcount, g=0, b=0, y=0.2, } spamcount = spamcount+1 end , 1000, 10) -- We're spamming at 1000ms with a timeout of 5000ms. -- Thanks to our destroyPlayerTimedText functions we can avoid -- overlapped text even though the timeout is higher than the spam delay end ) getPlayerCurrentText getPlayerCurrentText(player) Gets the text item of the text the specified player is seeing. If no text is displaying for the player, it returns nil Required Arguments: - player: the player who owns the text item Return Value: - The text item getPlayerCurrentDisplay getPlayerCurrentDisplay(player) Gets the display of the text the specified player is seeing. If no text is displaying for the player, it returns nil Required Arguments: - player: the player who owns the text item Return Value: - The display outputCountdown outputCountdown{ player, [start_value=3, delay=1000, go_text="Go!", x=0.5, y=0.5, priority="high", r=255, g=255, b=255, a=255, size=3, alignX="center", alignY="center", shadow_alpha=100, callback=nil, freeze=true] } Displays a countdown for the specified player. Required Arguments: - player: The player who will see the countdown. Optional Arguments: - start_value: The number from where it will start counting down. Must be over 1. - delay: the delay (in milliseconds) at which it will count down - go_text: The text that will be displayed once the countdown reaches zero - x: A floating point number between 0.0 and 1.0 indicating how far across the screen the text should be shown, as a percentage of the width, from the left hand side. - y: A floating point number between 0.0 and 1.0 indicating how far down the screen the text should be shown, as a percentage of the height, from the top. - priority: How important it is that this text should be up to date on client's screens. Valid values are: "low", "medium", "high". - r, g, b: Values between 0 and 255 indicating how red/green/blue the text should be. - a: A value between 0 and 255 indicating how transparent the text should be, with 0 being fully transparent, and 255 being opaque. - size: A floating point value indicating the scale of the text. The default is 1.0, which is around 12pt. - alignX: A string representing the X-alignment of the text. ("left", "center", "right") - alignY: A string representing the Y-alignment of the text. ("top", "center", "bottom") - shadow_alpha: A value between 0 and 255 indicating how dark the drop shadow should be. - callback: The function that will be called once the countdown reaches zero - freeze: A boolean value. If true, the player will be frozen until the countdown reaches zero. If omitted, it will be tru by default. Return Value: - true if the funtion succeeds, false otherwise Examples: -- Example 4 -- Using outputCountdown and its callback to set up a countdown command that will make you die after the "go" -- format: /killme seconds addCommandHandler("killme", function(source, cmdname, seconds) outputCountdown{ player = source, start_value = tonumber(seconds), go_text = "Die!", freeze = false, callback = function (source) killPed(source) end } end ) isPlayerInCountdown isPlayerInCountdown(player) Returns true if a countdown is displaying for the player Required Arguments: - player: The player Return Value: - true if a countdown is displaying for the player, false otherwise stopPlayerCountdown stopPlayerCountdown(player) Stops the player's countdown if there is any. Required Arguments: - player: The player
  2. Take a look at this snippet: addEventHandler("onPlayerVehicleExit", getRootElement(), function(vehicle, seat, jacker) if(seat == 0 and not starting_timeattack) then if(jacker == nil) then destroyElement(vehicle) setElementData(source, "current_vehicle", nil) else local jackername = getPlayerName(jacker) outputChatBox(jackername .. " tried to steal your car!", source) warpPedIntoVehicle(source, vehicle) end end if(starting_timeattack) then starting_timeattack = false else if(getElementData(source, "isChallengingAkinaTimeAttack")) then triggerEvent("quitAkinaTimeAttack", source) end end end ) jacker is supposed to be nil when no one is jacking you and you are just exiting your own car, right? Well, when i exit my own car without anyone jacking it, it still executes the part for getting jacked, this one: else local jackername = getPlayerName(jacker) outputChatBox(jackername .. " tried to steal your car!", source) warpPedIntoVehicle(source, vehicle) end and, of course, getPlayerName throws an invalid argument error
  3. That must be it :] I completely forgot about the LOD system. ill figure out how to split the hill I guess
  4. Mhm, thanks. At least i hope they fix custom vehicle collisions
  5. Hi, i'm trying to convert a single player modded map (Akina Downhill) to MTA by replacing some objects with the custom map models and placing them where they should be. The problem is, the map uses some pretty big objects (a huge unsolid hill plus 4 pretty big pieces of road with collisions). The pieces of road are almost decent (they fade in as you start driving on them), but the big problem is the giant hill that surrounds these pieces of road. Its completely invisibile except for a few view angles. This mod works perfectly in single player, so it must be something with MTA object system.
  6. As the title says, I would love to add my own ped models to have custom skins for the players. Also, will it fix vehicle custom collision?
  7. Try renaming it in .xml and open it with firefox, it will tel u the syntax errors
  8. lol nvm i tryed kewuk's way and it worked thanks anyways dn83 edit: i got another problem... when the player has the marker attached he should have infinite hp's but i just tested it and i was able to kill my friend while he had the marker
  9. but it should be global since it has not 'local' in front of it...
  10. I can't find any errors... here's the whole code: -- Simple DM - coded by Franc[e]sco --//--------------------------------------------------------------------------// local playerid = thePlayer local rSpawnPoints = {} killingSpreeDisplay = textCreateDisplay() killingSpreeActive = false killingSpreeMsg = textCreateTextItem("", 0.7, 0.05) textDisplayAddText(killingSpreeDisplay, killingSpreeMsg) --//--------------------------------------------------------------------------// function onPlayerSpawns ( ) playSoundFrontEnd(source, #rSpawnPoints) local rand = randInt(1, #rSpawnPoints) setElementPosition(source, rSpawnPoints[rand].x, rSpawnPoints[rand].y, rSpawnPoints[rand].z + 1) setPlayerRotation(source, rSpawnPoints[rand].f) setPlayerSkin(source, rSpawnPoints[rand].skin) giveWeapon(source, rSpawnPoints[rand].fist, 1) giveWeapon(source, rSpawnPoints[rand].melee, 1) giveWeapon(source, rSpawnPoints[rand].handgun, 200) giveWeapon(source, rSpawnPoints[rand].shotgun, 20) giveWeapon(source, rSpawnPoints[rand].smgun, 5000) giveWeapon(source, rSpawnPoints[rand].mgun, 5000) giveWeapon(source, rSpawnPoints[rand].rifle, 15) giveWeapon(source, rSpawnPoints[rand].heavy, 5) giveWeapon(source, rSpawnPoints[rand].projectile, 5) giveWeapon(source, rSpawnPoints[rand].special1, 30) giveWeapon(source, rSpawnPoints[rand].gift, 1) giveWeapon(source, rSpawnPoints[rand].special2, 1) giveWeapon(source, rSpawnPoints[rand].detonator, 1) if (getElementData(getElementByIndex("spawnprotect", 0), "activated") == "true") then setTimer(spawnProtectEnd, 5000, 1, source) setElementData(source, "spawnProtected", true) spawnProtectMarker = createMarker(0, 0, 0, "cylinder", 2, 255, 0, 0, 150) attachElementToElement(spawnProtectMarker, source) end end addEventHandler ( "onPlayerSpawn", getRootElement(), onPlayerSpawns ) --//--------------------------------------------------------------------------// function spawnThePlayer (playerid) spawnPlayer(playerid, 0.0,0.0,5.0, 0, 0) fadeCamera(playerid, true) toggleAllControls( playerid, true ) end --//--------------------------------------------------------------------------// function killThePlayer (playerid) killPlayer ( playerid, nil, 255, 4 ) end addCommandHandler("kill",killThePlayer) --//--------------------------------------------------------------------------// function onGmodeLoad (startedResource) print( "\nLOADED: Simple Deathmath by Franc[e]sco\n" ) spawns = getElementsByType ("spawnpoint") for k, v in pairs(spawns) do local x = getElementData(v,"x") local y = getElementData(v,"y") local z = getElementData(v,"z") local f = getElementData(v,"f") local fist = getElementData(v,"fist") local melee = getElementData(v,"melee") local handgun = getElementData(v,"handgun") local shotgun = getElementData(v,"shotgun") local smgun = getElementData(v,"smgun") local mgun = getElementData(v,"mgun") local rifle = getElementData(v,"rifle") local heavy = getElementData(v,"heavy") local projectile = getElementData(v,"projectile") local special1 = getElementData(v,"special1") local gift = getElementData(v,"gift") local special2 = getElementData(v,"special2") local detonator = getElementData(v,"detonator") local skin = getElementData(v, "skin") table.insert(rSpawnPoints, { x=x, y=y, z=z, f=f, fist=fist, melee=melee, handgun=handgun, shotgun=shotgun, smgun=smgun, mgun=mgun, rifle=rifle, heavy=heavy, projectile=projectile, special1=special1, gift=gift, special2=special2, detonator=detonator, skin=skin }) end setTimer(spawnEveryOne, 1500, 1) call(getResourceFromName("scoreboard"), "resetScoreboardColumns") call(getResourceFromName("scoreboard"), "addScoreboardColumn", "score") call(getResourceFromName("scoreboard"), "addScoreboardColumn", "killingspree") if (getElementData(getElementByIndex("killmessages", 0), "activated") == "true") then if (getResourceState(getResourceFromName("killmessages")) ~= "running") then startResource(getResourceFromName("killmessages")) end end end addEventHandler ( "onResourceStart", getRootElement (), onGmodeLoad ) --//--------------------------------------------------------------------------// function onGmodeEnd (theResourceStopped) if (getResourceState(getResourceFromName("killmessages")) == "running") then stopResource(getResourceFromName("killmessages")) end end addEventHandler ( "onResourceStop", getRootElement (), onGmodeEnd ) --//--------------------------------------------------------------------------// function spawnEveryOne () local playersToSpawn = getElementsByType ("player") for k,v in ipairs ( playersToSpawn ) do setTimer(spawnThePlayer, 1500, 1, v) setElementData ( v, "score", 0 ) setElementData ( v, "killingspree", 0 ) end end --//--------------------------------------------------------------------------// function destroyGameText (display) local everyPlayer = getElementsByType ("player") for k,v in ipairs (everyPlayer) do textDisplayRemoveObserver(display, v) end killingSpreeActive = false end --//--------------------------------------------------------------------------// function onPlayerConnect () local playerName = getClientName(source) sendClientMsg("Welcome, " .. playerName .. ", this server is actually running 'Simple Deathmatch by Franc[e]sco', enjoy your stay.", source, "green") setTimer(spawnThePlayer, 1500, 1, source) setElementData ( source, "score", 0 ) setElementData ( source, "killingspree", 0 ) if(killingSpreeActive == true) then textDisplayAddObserver(killingSpreeDisplay, source) end end addEventHandler("onPlayerJoin", getRootElement (), onPlayerConnect) --//--------------------------------------------------------------------------// function OnPlayerExit( reason ) setElementData( source, "score", 0 ) setElementData ( source, "killingspree", 0 ) end addEventHandler( "onPlayerQuit", getRootElement (), OnPlayerExit ) --//--------------------------------------------------------------------------// function onPlayerDeath (ammo, attacker, weapon, bodypart) setTimer(spawnThePlayer, 10000, 1, source) sendClientMsg("You died! 10 seconds till respawn", source, "red") if attacker then setElementData( attacker, "score", getElementData(attacker, "score")+1 ) setElementData( attacker, "killingspree", getElementData(attacker, "killingspree")+1 ) if (bodypart == 9) then sendClientMsgToAll("* " .. getClientName(attacker) .. " just headshotted " .. getClientName(source) .. " !", "green") elseif (bodypart == 4) then sendClientMsgToAll("* " .. getClientName(attacker) .. " just ass shotted " .. getClientName(source) .. " ! Ow, that hurts :(", "green") end if (getElementData(attacker, "killingspree") == 5) then textItemSetText(killingSpreeMsg, getClientName(attacker) .. " is dominating!") textItemSetColor(killingSpreeMsg, 255, 255, 255, 180) killingSpreeActive = true setTimer(destroyGameText, 5000, 1, killingSpreeDisplay) elseif (getElementData(attacker, "killingspree") == 10) then textItemSetText(killingSpreeMsg, getClientName(attacker) .. " is on a killing spree!") textItemSetColor(killingSpreeMsg, 255, 255, 0, 180) setTimer(destroyGameText, 5000, 1, killingSpreeDisplay) sendClientMsg("* You get 5 granades for your 10 kills", attacker) giveWeapon(attacker, 16, 5) killingSpreeActive = true elseif (getElementData(attacker, "killingspree") == 15) then textItemSetText(killingSpreeMsg, getClientName(attacker) .. " is unstoppable!") textItemSetColor(killingSpreeMsg, 255, 128, 64, 180) sendClientMsg("* You get 5 more granades for your 15 kills", attacker) giveWeapon(attacker, 16, 5) killingSpreeActive = true setTimer(destroyGameText, 5000, 1, killingSpreeDisplay) elseif (getElementData(attacker, "killingspree") == 20) then textItemSetText(killingSpreeMsg, getClientName(attacker) .. " owned the entire server!") textItemSetColor(killingSpreeMsg, 200, 0, 0, 180) setTimer(destroyGameText, 5000, 1, killingSpreeDisplay) sendClientMsg("* You get 10 more granades for your 20 kills", attacker) giveWeapon(attacker, 16, 10) killingSpreeActive = true end if (getElementData(source, "killingspree") > 5 and attacker ~= source) then sendClientMsgToAll("* " .. getClientName(attacker) .. " stopped " .. getClientName(source) .. " from doing " .. getElementData(source, "killingspree")+1 .. " straight kills!", "grey") end if(killingSpreeActive == true) then textItemSetScale(killingSpreeMsg, 3.0) local everyPlayer = getElementsByType ("player") for k,v in ipairs (everyPlayer) do textDisplayAddObserver(killingSpreeDisplay, v) end end end setElementData( source, "killingspree", 0 ) end addEventHandler("onPlayerWasted", getRootElement (), onPlayerDeath) --//--------------------------------------------------------------------------// function onPlayerDamaged (attacker, attackerweapon, bodypart, loss) if(getElementData ( source, "spawnprotected") == true) then setElementHealth(source, getElementHealth(source)+loss) elseif (getElementData(getElementByIndex("headshots", 0), "activated") == "true") then if(bodypart == 9) then killPlayer(source, attacker, attackerweapon, bodypart) end end end addEventHandler("onPlayerDamage", getRootElement (), onPlayerDamaged) --//--------------------------------------------------------------------------// function spawnProtectEnd (player) setElementData ( player, "spawnprotected", false ) detachElementFromElement(spawnProtectMarker, player) destroyElement(spawnProtectMarker) end --//--------------------------------------------------------------------------// function sendClientMsg (message, player, color) local r,g,b = 0, 0, 0 if (color == "red") then r = 206 g = 0 b = 5 elseif (color== "green") then r = 0 g = 187 b = 10 elseif (color == "grey") then r = 144 g = 144 b = 144 end outputChatBox(message, player, r, g, b) end --//--------------------------------------------------------------------------// function sendClientMsgToAll (message, color) local r,g,b = 0, 0, 0 if (color == "red") then r = 206 g = 0 b = 5 elseif (color== "green") then r = 0 g = 187 b = 10 elseif (color == "grey") then r = 144 g = 144 b = 144 end outputChatBox(message, getRootElement (), r, g, b) end --//--------------------------------------------------------------------------//
  11. wtf now it gives bad argument at the detach function too
  12. I got a problem... i'm adding the final touches to my gamemode... and i added a spawnkilling protection... to make it look nicer i attach a cylinder marker to the player until the spawnkilling protection goes down (5 secs)... and destroy element says bad argument when it should destroy the marker... here's some snippets from the code: If the spawn protection is setted to true in the map file and a player spawns, create the marker and set the timer to destroy the marker. if (getElementData(getElementByIndex("spawnprotect", 0), "activated") == "true") then setTimer(spawnProtectEnd, 5000, 1, source) setElementData(source, "spawnProtected", true) spawnProtectMarker = createMarker(0, 0, 0, "cylinder", 2, 255, 0, 0, 150) attachElementToElement(spawnProtectMarker, source) end If the player is spawn protected recover his loss when someone shoots him and don't allow headshots on him function onPlayerDamaged (attacker, attackerweapon, bodypart, loss) if(getElementData ( source, "spawnprotected") == true) then setElementHealth(source, getElementHealth(source)+loss) elseif (getElementData(getElementByIndex("headshots", 0), "activated") == "true") then if(bodypart == 9) then killPlayer(source, attacker, attackerweapon, bodypart) end end end addEventHandler("onPlayerDamage", getRootElement (), onPlayerDamaged) Destroy the marker and remove spawn protection function spawnProtectEnd (player) setElementData ( player, "spawnprotected", false ) destroyElement(spawnProtectMarker) end
  13. NVM, i solved removing also the observers from the text display when i remove the textItem