Jump to content


  • Posts

  • Joined

  • Last visited


  • Location
  • Occupation
  • Interests
    Soccer and games

Recent Profile Visitors

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

Ace_Gambit's Achievements


Mack (28/54)



  1. Your only work-around at the moment is find the right shooting animation and do the rest manually with effect and audio functions.
  2. Erm... typo But, seriously stop posting if you don't have anything to say. This isn't a chat box. Absolute to relative example: screenWidth, screenHeight = guiGetScreenSize() imageWidth = 50 imageHeight = 50 relImageWidth = imageWidth / screenWidth relImageHeight = imageHeight / screenHeight
  3. Relative sizes are usually calculated by dividing the absolute value by the value relative to. Just imagine your GUI window has a width of 200 pixels and the resolution of your screen is 800 x 600 pixels. The relative value is 200 / 800 = 0.25.
  4. That's exactly my thought. Ideally you can add/remove tasks at runtime (something like setNPCTasks ( table tasks )) and have a less obvious way with xml files. The latter is primarily meant for NPC's that perform a fixed list of tasks (like shop owners).
  5. NPC Animation Classes 0.2 Getting Started Extract npcac.zip to the root folder of your resource. The most recent version is attached at the bottom of this post. Now add the following lines to meta.xml. This is required. <script src="npcac/shared/include/const.inc" type="server" /> <script src="npcac/shared/include/type.inc" type="server" /> <script src="npcac/shared/include/util.inc" type="server" /> <script src="npcac/shared/objects/CPath.obj" type="server" /> <script src="npcac/shared/objects/CAnim.obj" type="server" /> <script src="npcac/shared/objects/CPause.obj" type="server" /> <script src="npcac/shared/anim/npc/CStaticPed.npc" type="server" /> <script src="npcac/shared/include/const.inc" type="client" /> <script src="npcac/shared/include/type.inc" type="client" /> <script src="npcac/shared/include/util.inc" type="client" /> <script src="npcac/shared/objects/CPath.obj" type="client" /> <script src="npcac/shared/objects/CAnim.obj" type="client" /> <script src="npcac/shared/objects/CPause.obj" type="client" /> <script src="npcac/shared/anim/npc/CStaticPed.npc" type="client" /> <script src="npcac/server/include/const.inc" type="server" /> <script src="npcac/server/debug/CDebug.lua" type="server" /> <script src="npcac/server/CNPC.lua" type="server" /> <script src="npcac/client/include/const.inc" type="client" /> <script src="npcac/client/objects/CLook.obj" type="client" /> <script src="npcac/client/debug/CDebug.lua" type="client" /> <script src="npcac/client/CStaticAnimator.lua" type="client" /> <script src="npcac/client/CNPC.lua" type="client" /> <file src="npcac/client/anim/npc.xml" /> <script src="npcac/server/npcac.lua" type="server" /> <script src="npcac/client/npcac.lua" type="client" /> You are now ready to add NPC's! Adding NPC's Adding NPC's is easy. There are two XML files to add NPC's. npcac/client/anim/npc.xml npcac/server/anim/npc.xml The only main difference at the moment is that the former (client NPC XML) does not support weapon elements. Every NPC XML must have a root node. <npc> </npc> You can add a NPC block but this is optional. NPC blocks are used to group NPC's in case of a large population. <npc> <BOMBER> </BOMBER> </npc> Adding NPC's is just like you are used to with MTA map elements. This version only supports ped elements at the moment. <npc> <BOMBER> <npc-ped> <ped id="Herbert" model="259" posX="-15" posY="-15" posZ="3" pose="crouch"> <!-- This is where you can add task elements --> </ped> </npc-ped> </BOMBER> </npc> Notice the npc-ped element. This is required as well and tells the script what type of NPC it should expect. In the future I will add other NPC types like npc-object, npc-camera and npc-vehicle (even though these aren't really considered "real" NPC's). It is important to notice that ped elements must have a ID. The only (non-standard) optional attribute is pose. The pose attribute determines the initial pose. Weapons As mentioned before you can give weapons to ped NPC's. Weapons are a special type of task elements as they are not really tasks. Weapon elements can only be added to the server-side NPC XML. The XML syntax for weapon elements is. <weapon weapon="" ammo="" setAsCurrent="" /> weapon: The weapon ID. ammo: Ammo amount for the given weapon. setAsCurrent: Determines whether or not the weapon will be set as current (true or false). You are now ready to add tasks. Tasks Tasks are ordinary elements as well. The task list goes from top to bottom. The XML syntax for supported tasks is as follows. Path Make a ped walk to a specified target position. <path targetX="" targetY="" block="" name="" stepRotZ="" interruptible="" targetMinAngle="" targetMinDist="" /> targetX: The x coordinate of the world position to target at. targetY: The y coordinate of the world position to target at. block: The animation block's name. name: The name of the animation within the block. stepRotZ: Steps to turn every frame (high number means fast rotation). interruptible: Determines whether or not the NPC is allowed to be interrupted while performing this task (true or false). targetMinAngle: Minimum angle between facing direction and target before the NPC stops rotating towards its destination. targetMinDist: Minimum distance to destination before the NPC completes this task. Anim Set ped animation. <anim time="" block="" name="" loop="" updatePosition="" interruptible="" /> time: The duration for the animation. block: The animation block's name. name: The name of the animation within the block. loop: Indicates whether or not the animation will loop (true or false). updatePosition: Will change the actual coordinates of the ped according to the animation (true or false). interruptible: Defines whether the animation can be interrupted by normal movements (true or false). Look Make a ped look at a specified target position or ped. <look targetX="" targetY="" targetZ="" time="" target="" blocking="" /> targetX: The x coordinate of the world position to look at. targetY: The y coordinate of the world position to look at. targetZ: The z coordinate of the world position to look at. time: The time, in milliseconds, during which the ped will look at the target. target: The target ID. If this argument is specified, the position arguments will be ignored and the ped's gaze will follow the specified element instead. Can be a player, a vehicle, another ped etc. blocking: Determines whether or not the ped should interrupt all other tasks and complete looking at the target before proceeding (true or false). Pause Suspend the task list for a specified number of milliseconds. <pause time="" resume="" /> time: The duration to suspend all tasks. resume: Determines whether or not the task list will go into play state again or remain paused until the script explicitly tells it to resume (true or false). Putting It Together Example NPC XML (client). <npc> <BOMBER> <npc-ped> <ped id="Herbert" model="259" posX="-15" posY="-15" posZ="3" pose="crouch"> <path targetX="30" targetY="30" block="ped" name="WALK_civi" stepRotZ="1.0" interruptible="true" targetMinAngle="2.0" targetMinDist="2.5" /> <look targetX="0" targetY="0" targetZ="0" time="2500" target="Herald" blocking="false" /> <path targetX="30" targetY="10" block="ped" name="WALK_civi" stepRotZ="1.0" interruptible="true" targetMinAngle="2.0" targetMinDist="2.5" /> <anim time="0" block="ped" name="idle_stance" loop="false" updatePosition="false" interruptible="false" /> <look targetX="0" targetY="0" targetZ="0" time="2500" target="Herald" blocking="true" /> <look targetX="30" targetY="30" targetZ="5" targetID="" time="2500" blocking="true" /> <path targetX="10" targetY="30" block="ped" name="WALK_civi" stepRotZ="1.0" interruptible="true" targetMinAngle="2.0" targetMinDist="2.5" /> <look targetX="0" targetY="0" targetZ="0" time="2500" target="Herald" blocking="false" /> <pause time="5000" resume="true" /> <look targetX="30" targetY="30" targetZ="5" targetID="" time="2500" blocking="true" /> <anim time="3000" block="BOMBER" name="BOM_Plant" loop="false" updatePosition="false" interruptible="false" /> </ped> </npc-ped> </BOMBER> </npc> Example NPC XML (server). <npc> <SWAT> <npc-ped> <ped id="Herald" model="285" posX="-15" posY="-5" posZ="3" pose="armed"> <weapon weapon="29" ammo="30" setAsCurrent="true" /> <anim time="3000" block="UZI" name="UZI_crouchreload" loop="false" updatePosition="false" interruptible="false" /> </ped> </npc-ped> </SWAT> </npc> Task List States Now that we have created our NPC's we want to see some action. We can do so by putting the task list into play state by invoking the play method of our NPC instance. Every NPC is member of the global NPC table instance created by the NPC Animation Classes. You can access each NPC by NPC block ID (optional) and NPC ID (required). For example NPC.SWAT.Herald points to our server-side created NPC (see NPC XML example). Available task list states are: start: start ( [ bool loop=false ] ). stop: stop ( void ). pause: pause ( [ float time=0, bool resume=false ] ). resume: resume ( void ). Events The following events are available. onNPCTask ( string taskName, int taskPosition ) onNPCTaskStart ( void ) onNPCTaskStop ( void ) onNPCTaskPause ( int taskPosition, float timeInterval, boolean resume ) onNPCTaskResume ( int taskPosition ) Lua Example function onNPCTask ( szTaskName, iTaskPos ) outputChatBox ( "* NPC Task: " .. ( tonumber ( iTaskPos ) or -1 ) .. " is of type " .. szTaskName ); if ( iTaskPos == 2 ) then NPC.SWAT.Herald:start (); end; end; function onClientResourceStart ( pStartedResource ) if ( pStartedResource == getThisResource () ) then addEvent ( "onNPCTask", false ); addEventHandler ( "onNPCTask", NPC.BOMBER.Herbert:getPed (), onNPCTask ); NPC.BOMBER.Herbert:start (); end; end; addEventHandler ( "onClientResourceStart", getRootElement (), onClientResourceStart, true ); Important Notes: If the attribute "interruptible" is enabled for path tasks causing damage to the NPC will clear all tasks currently waiting. The "NPC" variable is the global NPC table instance. If you want the actual MTA element you must invoke the getPed() method on a NPC member. NPC tasks are MTA elements. In theory this allows you to make editor definitions and place path nodes. In practice path tasks are almost the same as anim tasks. This means that in theory you can use any animation. The animator however only keeps track of the NPC's position causing it to go into infinite play state if the NPC does not move. Changes You'll probably find mistakes in the script but that's because I am cleaning my entire game mode script and may forgot to change things properly.
  6. The reason it doesn't go in a straight line is because the update interval is not fast enough to correct the turn velocity. The vehicle is constantly "pushed" in the right direction but it "overshoots" the facing angle because it can't correct the heading fast enough. Ideally you would do this client-side every time a new frame is rendered. But because there is no such thing server-side it looks as if it's swinging from left to right.
  7. Just keep in mind that the math used in this example is really rough and dirty. I am sure most of it can be done in less lines of script. But it may help you anyway.
  8. Have a look at this. https://forum.multitheftauto.com/viewtop ... 91&t=24188 It's a very basic example of moving a vehicle server-side (without any obstacle checking).
  9. Yea well. There is a major difference between needed and wanted. Your server isn't going to crash if you can't pick special character skins. And besides, there are more than enough skins to go with atm. It's just an addition you'd like to have. But like someone said before, this has been discussed so many times it's not even funny. And every time we came to the same conclusion. It's very unlikely it will happen before 1.0 so give it a rest.
  10. Why? It's not that important if you compare it to optimizing synchronization and other more serious issues.
  11. My best guess is he's going to ask why his screen remains black when he joins his server.
  12. That's not true. You can call setTimer anywhere and anytime you want. Even when it's in the body of your script.
  13. Ace_Gambit

    max value

    bla = {} bla[500] = "player1" bla[1000] = "player2" bla[2000] = "player3" print(bla[table.maxn(bla)].." has the highest score.")
  14. I honestly think this thread is going in the wrong direction. We are in the scripting section of the forums. Maybe it's best you seek help somewhere else, seriously.
  15. Dude, these are so sweet. What editor are you using?
  • Create New...