GTAMP.com

Grand Theft Auto Media Press
It is currently Fri Aug 01, 2014 10:28 pm

All times are UTC




Post new topic Reply to topic  [ 44 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Code Snippets
PostPosted: Wed May 26, 2010 10:33 am 
Offline
Psycho

Joined: Wed Jul 29, 2009 8:22 pm
Posts: 60
One script for one post, add full description please.

I love code snippets. It makes developing process easier. GTA2 scripting is not a hard task at all, the script is self-documented. But sometimes I see codes that are interesting, have something in them that I haven't seen before. It's a good idea to share these.

Kill people by punching them:
Syntax: [ Download ] [ Hide ]
Using GTA2 Script Syntax Highlighting
IF (CHECK_CHARACTER_HEALTH(p1, 0))
    IF ( HAS_CHAR_PUNCHED_SOMEONE  ( p1 ))
        STORE_LAST_CHAR_PUNCHED ( p1 , p1punched )
        KILL_CHAR ( p1punched )
    ENDIF
ENDIF
Parsed in 0.021 seconds, using GeSHi 1.0.8.10



Please post any worthy code snippet.
Happy coding!


Top
 Profile  
 
 Post subject: Re: Code Snippets
PostPosted: Wed May 26, 2010 3:51 pm 
Offline
User avatar

Joined: Mon May 18, 2009 9:40 pm
Posts: 406
Location: Nowhere.
No Cops:
Code:
DECLARE_POLICELEVEL ( 0 )
MAP_ZONE map = ( 1000 , 600, 300 , 0 , 1000 , 20 , 20 , 200, 0 , 000 , 0 )

That will set maximum wanted level to zero and remove all cops and cop cars from the map (only setting max wanted to 0 will still let cops drive and walk around and you may still get a wanted level when a cop sees you doing something wrong, though it will disappear quicker than normal)

_________________
You just lost the game.


Top
 Profile  
 
 Post subject: Re: Code Snippets
PostPosted: Wed May 26, 2010 4:16 pm 
Offline
User avatar

Joined: Wed Mar 17, 2010 4:07 am
Posts: 401
Location: Wales, UK
Useful little thing to add delays while inside a WHILE_EXEC or WHILE loop (by default they are skipped if they are inside these code bits), useful if you want timed explosions etc while still having proper IF functions...

Proper Delaying in WHILE/WHILE_EXEC Loops

Put this before LEVELSTART...
Code:
wait_short:
DELAY_HERE ( 30 )
RETURN


Extremely short bit of code. The "wait_short:" is the label name (you must include the colon at the end of the name!) and then put anything you like inbetween the label name and the "RETURN". Adjust your "DELAY_HERE" count to whatever you need (30 "game ticks" is 1 second real time).

When you are ready to use it in your script simply do this...

Code:
GOSUB wait_short:


Throw that in wherever you like, again, don't forget the colon at the end of the label name! 8-)

_________________


Top
 Profile  
 
 Post subject: Re: Code Snippets
PostPosted: Wed May 26, 2010 4:55 pm 
Offline
Lunatic

Joined: Sat Jul 19, 2008 2:14 pm
Posts: 434
Location: Poland / Szczecin
Remote Mini Deadly Cars:
Allow each player to remotly drive a minicar with vechicleguns (or whatever) once per death. That service costs X$ ofcourse. Please test that script... I didn`t check it yet.
Code:
PLAYER_PED playerx = (X.x , Y.y , Z.0) remap  angle // first spawn of that player also his remap and angle
CHAR_DATA uniquenamex
COUNTER loop = 1 // basic loop
COUNTER playerxdeath = 1 // player x death counter
LEVELSTART
WHILE_EXEC ( loop = 1 )
IF (CHECK_CHARACTER_HEALTH(playerx, 0)) // checks whether the player is in game
IF (playerxdeath = 1) // checks whether the player died before
IF (LOCATE_CHARACTER_ANY_MEANS ( playerx  ,  X.x  , Y.y , Z.0  , width , height )) // place in which the player must be by car or foot (you can change ANY_MEANS to BY_FOOT or BY_CAR - but check it I don`t rly rememer )
IF (CHECK_SCORE_GREATER (playerx, cash)) // Checks player`s score
ADD_SCORE (playerx, -cash) // takes player`s
uniquenamex = CREATE_CAR ( X.x , Y.y , Z.0 ) remap angle cartype MINI_CAR END // Creates mini car in specific place. Also declares car`s remap and angle and type. If you want to have remote car (not mini) so you have to remove MINI_CAR
GIVE_WEAPON (uniquenamex , wepontype, ammount) // gives car weapon to your car
TAKE_REMOTE_CONTROL_OF_CAR (playerx, uniquenamex) // gives you power to remotly control car
SET playerxdeath = 0
ENDIF
ENDIF
ENDIF
ENDIF
IF ( HAS_CHARACTER_DIED (playerx ) ) // check whether the player has died
DELETE_ITEM ( p1g ) // if he did it script sets couter to 1
SET playerxdeath = 1
ENDIF
ENDWHILE
LEVELEND


And example:
Code:
PLAYER_PED p1 = (176.5 , 147.5 , 2.0) 10  0
CAR_DATA remdem1
COUNTER loop = 1
COUNTER p1d = 0
LEVELSTART
WHILE_EXEC ( loop = 1 )
IF (CHECK_CHARACTER_HEALTH(p1, 0))
IF (p1d = 1)
IF (LOCATE_CHARACTER_ANY_MEANS ( p1  ,  197.5  , 203.5 , 2.0  , 1.0 , 1.0 ))
IF (CHECK_SCORE_GREATER (p1, 5999))
ADD_SCORE (p1, -6000)
remdem1 = CREATE_CAR ( 169.5 , 155.5 , 2.0 ) 2 180 ISETTA MINI_CAR END
GIVE_WEAPON (remdem1, CAR_MACHINE_GUN, 50)
TAKE_REMOTE_CONTROL_OF_CAR (p1, remdem1)
SET p1d = 0
ENDIF
ENDIF
ENDIF
ENDIF
IF ( HAS_CHARACTER_DIED ( p1 ) )
SET p1d = 1
ENDIF
ENDWHILE
LEVELEND


Top
 Profile  
 
 Post subject: Re: Code Snippets
PostPosted: Wed May 26, 2010 5:03 pm 
Offline
Lunatic

Joined: Sat Jul 19, 2008 2:14 pm
Posts: 434
Location: Poland / Szczecin
Shazdeh wrote:
Do something with cars that player gets in:
Code:
IF (CHECK_CHARACTER_HEALTH(p1, 0))
   IF (IS_CHARACTER_IN_ANY_CAR  ( p1  ) )
      STORE_CAR_CHARACTER_IS_IN ( p1  ,  bum1  )
      // do something with bum1. like: EXPLODE_SMALL (bum1)
   ENDIF
ENDIF


Top
 Profile  
 
 Post subject: Re: Code Snippets
PostPosted: Wed May 26, 2010 8:54 pm 
Offline
Psycho

Joined: Wed Jul 29, 2009 8:22 pm
Posts: 60
No Cops, the other method:
It doesn't removes the cops or cop cars, they simply ignore the player.
Use this inside the loop.

Code:
IF (CHECK_HEADS_GREATER(p1, 0) )
   CLEAR_WANTED_LEVEL(p1)
ENDIF


Top
 Profile  
 
 Post subject: Re: Code Snippets
PostPosted: Thu May 27, 2010 5:20 pm 
Offline
User avatar

Joined: Wed Mar 17, 2010 4:07 am
Posts: 401
Location: Wales, UK
Player passengers in cars...

Put inside WHILE/WHILE_EXEC loop... this constantly updates whatever car the player is in and saves it for future use and then checks to see if player 2 is holding an electro baton while player 1 is pressing the car horn. If both are true then orders player 2 to the back door of player 1's current car. This will stop if player 2 switches weapons and/or player 1 stops pressing the horn. Set up multiple ones for different players and you you can have multiple players as passengers!

Code:
STORE_CAR_CHARACTER_IS_IN ( p1 , p1_current_car )

IF ( ( CHECK_CHAR_CURR_WEAPON ( p2 , ELECTRO_BATON ) )
AND ( IS_CHAR_PRESSING_HORN ( p1 ) ) )
SET_CHAR_OBJECTIVE ( p2 , ENTER_CAR_AS_PASSENGER , p1_current_car )
ENDIF


Edit: Don't forget you need a CAR_DATA command elsewhere to use this! In this case it'd be "CAR_DATA p1_current_car".

_________________


Last edited by Pyro on Thu May 27, 2010 10:09 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Suicide!
PostPosted: Thu Jun 10, 2010 11:37 am 
Offline
Psycho

Joined: Wed Jul 29, 2009 8:22 pm
Posts: 60
Suicide!
Your dummy bot gets in a car and will explode itself when it gets to the player. This snippet has been taken from Harbor Town.
Use this inside 'the loop'.

Code:
IF ( LOCATE_ANOTHER_CHARACTER_BY_CAR ( Bot1 , Player1 , 2.0 , 2.0 ) )
IF ( NOT ( HAS_CHARACTER_DIED ( Bot1 ) ) )
EXPLODE_LARGE ( Bot1 )
ENDIF
ENDIF


Top
 Profile  
 
PostPosted: Thu Jun 10, 2010 11:41 am 
Offline
Psycho

Joined: Wed Jul 29, 2009 8:22 pm
Posts: 60
Make NPC's use car weapons (Tanks, FireTrucks, Jeeps, ...)

Code:
SET_CHAR_TO_USE_CAR_WEAPON ( x , ON )
SET_FAVOURITE_MODEL ( x, GUNJEEP )

x is the NPC's name.


Top
 Profile  
 
 Post subject: Re: Code Snippets
PostPosted: Sat Jun 12, 2010 12:55 pm 
Offline
Boss
User avatar

Joined: Tue Mar 04, 2008 6:51 am
Posts: 1070
Location: GTAMP.com
A boss ped that takes 3 rocket hits to kill:

Syntax: [ Download ] [ Hide ]
Using GTA2 Script Syntax Highlighting
// bil.sty bil.gmp bossman.scr

PLAYER_PED player = (49.5, 46.5, 5.0) 1 0
PARKED_CAR_DATA player_car = (52.5, 46.5, 5.0) 0 0 GT24640
CHAR_DATA bossman = ( 50.5 , 46.5 , 5.0 ) 0 180 MUGGER

COUNTER true = 1
COUNTER bosslife = 3 // bossman needs to be hit this number of times to die

LEVELSTART

WHILE ( true = 1 ) // the basic loop

SET_CHAR_GRAPHIC_TYPE (player, DUMMY_GRAPHIC , 26)
GIVE_WEAPON ( player_car, CAR_MINE )
SET_CHAR_INVINCIBLE ( bossman , ON )
SET_CHAR_INVINCIBLE ( player , ON )
GIVE_WEAPON ( player , ROCKET_LAUNCHER )

//checks if bossman is hit with a rocket
IF ( CHECK_WEAPON_TYPE_HIT_CHAR ( bossman , BY_ROCKET_LAUNCHER ))
ADD_SCORE ( player , 1 )
--bosslife
ENDIF

IF ( bosslife < 1 )
KILL_CHAR ( bossman)
SET bosslife = 3
ENDIF

ENDWHILE // basic loop

LEVELEND

/*
Damage Types
BY_EXPLOSION
BY_DROWNING
BY_PUNCH
BY_GUN
BY_CAR_BOMB
BY_FIRE
BY_FLAMETHROWER
BY_GRENADE
BY_MOLOTOV
BY_ROCKET_LAUNCHER
BY_ELECTRO_WEAPON
BY_SHOTGUN
BY_WATER_CANNON
BY_ANY_WEAPON
BY_ANY_FOOT_WEAPON
*/
Parsed in 0.024 seconds, using GeSHi 1.0.8.10

You could create a boss that can only be killed by water cannon, some kind of super villain with a weakness. Electrogun will always kill so you'd have to remove that.


Top
 Profile  
 
 Post subject: Re: Code Snippets
PostPosted: Wed Jun 23, 2010 4:41 pm 
Offline
User avatar

Joined: Wed Mar 17, 2010 4:07 am
Posts: 401
Location: Wales, UK
Scripted Instant-Gang

This code let's you have a custom instant gang that will also replace the missing members if they are dead. This example is done by using a phone but can be changed to whatever you like, and also you can add more members if needs be.

Syntax: [ Download ] [ Hide ]
Using GTA2 Script Syntax Highlighting
CHAR_DATA p1_group_member01
CHAR_DATA p1_group_member02
OBJ_DATA phone_1 = ( 191.7 , 51.5 , 255.0 ) 000 PHONE

COUNTER loop = 1
COUNTER p1_group_member01_died = 1
COUNTER p1_group_member02_died = 1

FORWARD p1_group:

THREAD_TRIGGER thr_p1_group = THREAD_WAIT_FOR_ANSWER_PHONE(p1, phone_1, p1_group:)
p1_group:
  // 1st Inmate:
  IF (p1_group_member01_died = 1)
    SET p1_group_member01_died = 0
    p1_group_member01 = CREATE_CHAR (188.3,51.2,255.0) 2 180 CRIMINAL END
    ADD_EXISTING_CHAR_TO_GROUP(p1, p1_group_member01)
    GIVE_WEAPON (p1_group_member01, PISTOL)
  ENDIF
  // 2nd Inmate:
  IF (p1_group_member02_died = 1)
    SET p1_group_member02_died = 0
    p1_group_member02 = CREATE_CHAR (188.5,51.8,255.0) 2 180 CRIMINAL END
    ADD_EXISTING_CHAR_TO_GROUP (p1, p1_group_member02)
    GIVE_WEAPON (p1_group_member02, PISTOL)
  ENDIF
RETURN

LEVELSTART

ADD_GROUP_TO_CHARACTER(p1, 0)

WHILE_EXEC (loop = 1)
  // Inmate Gang Death Check:
  IF ( HAS_CHARACTER_DIED(p1_group_member01) )
    SET p1_group_member01_died = 1
  ENDIF
  IF ( HAS_CHARACTER_DIED(p1_group_member02) )
    SET p1_group_member02_died = 1
  ENDIF
ENDWHILE

LEVELEND
Parsed in 0.026 seconds, using GeSHi 1.0.8.10


Original code by myself with modifications by Ben 8-)

(This is released as unstable until we have a fix - it will currently not work properly if you die and answer the phone again)

_________________


Top
 Profile  
 
 Post subject: Re: Code Snippets
PostPosted: Wed Aug 04, 2010 12:06 pm 
Offline
Boss
User avatar

Joined: Tue Mar 04, 2008 6:51 am
Posts: 1070
Location: GTAMP.com
Create 16 bots that try to kill player1:

Syntax: [ Download ] [ Hide ]
Using GTA2 Script Syntax Highlighting
PLAYER_PED player1 = (90.0, 93.5, 255.0) 10 0
counter bots = 0
counter loop = 1
char_data botgroup

LEVELSTART

botgroup = CREATE_CHAR ( 92.0 , 91.5 , 3.0 ) 7 90 CRIMINAL_TYPE1 END

WHILE_EXEC ( loop = 1 )

IF ( bots < 16 )
  IF ( NOT ( delay (10) ))
     ++bots
     botgroup = CREATE_CHAR ( 92.0 , 91.5 , 4.0 ) 7 90 CRIMINAL_TYPE1 END
     SET_CHAR_GRAPHIC_TYPE ( botgroup , DUMMY_GRAPHIC , 26 )
     GIVE_WEAPON ( botgroup , ROCKET_LAUNCHER )
     SET_CHAR_BRAVERY_LEVEL ( botgroup , LOONY )
     SET_CHAR_SHOOTING_SKILL ( botgroup , CRACK_SHOT )
     SET_CHAR_THREAT_REACTION ( botgroup , NO_REACTION )  
     SET_CHAR_INVINCIBLE ( botgroup , ON )
     SET_FAVOURITE_MODEL  ( botgroup , GUNJEEP )
     SET_CHAR_TO_USE_CAR_WEAPON  ( botgroup , ON )
     SET_CHAR_OBJECTIVE ( botgroup, KILL_CHAR_ANY_MEANS , player1 )
  ENDIF
ENDIF

ENDWHILE

LEVELEND
Parsed in 0.024 seconds, using GeSHi 1.0.8.10

If you want them to drive cars then it becomes unstable with more than 16 bots but on foot you can have more than 70 bots after you. This script was quickly tested with bil.sty and bil.gmp. I haven't tested it multiplayer.


Top
 Profile  
 
 Post subject: Re: Code Snippets
PostPosted: Wed Aug 18, 2010 9:35 pm 
Offline
User avatar

Joined: Sat Dec 26, 2009 11:53 pm
Posts: 964
I think, like me, many of you have once tried this function:
SET_CAR_NO_COLLIDE ()
but did not see an effect.
It is used for the the car at the Residential start point.
This car cannot be pushed and can move shove even the heaviest vehicle away.

The trick: put it in the while loop

Code:
PLAYER_PED p1 = ( 104.5, 100.7, 255.0 ) 10 0
PARKED_CAR_DATA car = (124.5, 131.5) 31 90 STRIPETB
COUNTER loop = 1

LEVELSTART
WHILE ( loop = 1 )

SET_CAR_NO_COLLIDE (car)

ENDWHILE
LEVELEND

_________________
yur sa'nok ngeyä


Top
 Profile  
 
 Post subject: Re: Code Snippets
PostPosted: Mon Aug 23, 2010 8:28 pm 
Offline
User avatar

Joined: Sat Dec 26, 2009 11:53 pm
Posts: 964
Army script:

the maximum wanted level is 6 and at the beginning and after death it is set to 4.

Code:
// Players
PLAYER_PED p1 = (57.5, 129.5, 255.0) 10 0
PLAYER_PED p2 = (73.5, 120.5, 255.0) 13 90
PLAYER_PED p3 = (93.5, 114.5, 255.0) 7 270
PLAYER_PED p4 = (52.5, 111.5, 255.0) 11 0
PLAYER_PED p5 = (67.5, 114.5, 255.0) 9 90
PLAYER_PED p6 = (70.5, 131.5, 255.0) 0 270

COUNTER loop = 1
DECLARE_POLICELEVEL (6)


LEVELSTART

SET_AMBIENT_LEVEL (1.0, 0)

IF (CHECK_CHARACTER_HEALTH(p1, 0)) // dummy check to avoid crash
ALTER_WANTED_LEVEL  (  p1  ,  4  ) // SWAT
ENDIF

IF (CHECK_CHARACTER_HEALTH(p2, 0))
ALTER_WANTED_LEVEL  (  p2  ,  4  )
ENDIF
IF (CHECK_CHARACTER_HEALTH(p3, 0))
ALTER_WANTED_LEVEL  (  p3  ,  4  )
ENDIF
IF (CHECK_CHARACTER_HEALTH(p4, 0))
ALTER_WANTED_LEVEL  (  p4  ,  4  )
ENDIF
IF (CHECK_CHARACTER_HEALTH(p5, 0))
ALTER_WANTED_LEVEL  (  p5  ,  4  )
ENDIF
IF (CHECK_CHARACTER_HEALTH(p6, 0))
ALTER_WANTED_LEVEL  (  p6  ,  4  )
ENDIF

WHILE ( loop = 1 )

IF (HAS_CHARACTER_DIED(p1))
DELAY_HERE ( 150 ) //needed to get wanted level reliably
ALTER_WANTED_LEVEL (p1, 4) //SWAT
ENDIF

IF (HAS_CHARACTER_DIED(p2))
DELAY_HERE ( 150 )
ALTER_WANTED_LEVEL (p2, 4)
ENDIF
IF (HAS_CHARACTER_DIED(p3))
DELAY_HERE ( 150 )
ALTER_WANTED_LEVEL (p3, 4)
ENDIF
IF (HAS_CHARACTER_DIED(p4))
DELAY_HERE ( 150 )
ALTER_WANTED_LEVEL (p4, 4)
ENDIF
IF (HAS_CHARACTER_DIED(p5))
DELAY_HERE ( 150 )
ALTER_WANTED_LEVEL (p5, 4)
ENDIF
IF (HAS_CHARACTER_DIED(p6))
DELAY_HERE ( 150 )
ALTER_WANTED_LEVEL (p6, 4)
ENDIF

ENDWHILE

LEVELEND



_________________
yur sa'nok ngeyä


Top
 Profile  
 
 Post subject: Re: Code Snippets
PostPosted: Thu Nov 11, 2010 11:27 pm 
Offline

Joined: Sat May 16, 2009 6:14 am
Posts: 852
Location: London, UK
All of the GTA2 radio station codes, with the locations found using TM's script decompiler which is available through his Epic Map Editor. Strangely missing krez though?
Code:
// Radio Stations
// Downtown (wil.*)
RADIO_STATION rockstar = STATION_DOWNTOWN    (212.5,022.5)
RADIO_STATION futuro   = STATION_ZAIBATSU    (155.5,004.5)
RADIO_STATION funami   = STATION_YAKUZA      (247.5,027.5)
RADIO_STATION lithium  = STATION_LOONIE      (150.5,039.5)

// Residential (ste.*)
RADIO_STATION krez     = STATION_RESIDENTIAL (166.5,103.5)
RADIO_STATION futuro   = STATION_ZAIBATSU    (247.5,067.5)
RADIO_STATION rebel    = STATION_REDNECK     (041.5,048.5)
RADIO_STATION osmosis  = STATION_SCIENTIST   (211.5,229.5)

// Industrial (bil.*)
RADIO_STATION lofi     = STATION_INDUSTRIAL  (110.5,108.5)
RADIO_STATION heavenly = STATION_KRISHNA     (242.5,214.5)
RADIO_STATION kgbh     = STATION_RUSSIAN     (201.5,021.5)
RADIO_STATION futuro   = STATION_ZAIBATSU    (020.5,230.5)

Radio Stations on GTA2 Wiki documents which stations are on which single-player levels, along with their in-game logo. Lantyz figured out the original multiplayer level radio station codes. My sample is copied from Lantyz's work.

(EDIT) It seems only the first four you declare will be used in-game. All levels get Head Radio - you can't declare that specifically and can't prevent it being available.

(EDIT) Tutorial with sample code and references now available:

_________________
BenMillard's GTA5 Races, Off-Roading and Deathmatches | GTA2 Multiplayer Levels | Mission Code Tutorials | GTA2 YouTube Videos


Last edited by BenMillard on Sun Jan 29, 2012 7:57 pm, edited 4 times in total.

Top
 Profile  
 
 Post subject: Re: Code Snippets
PostPosted: Thu Dec 02, 2010 12:38 am 
Offline
User avatar

Joined: Sat Dec 26, 2009 11:53 pm
Posts: 964
race respawn checkpoint
-all respwan zones must be in the teleporter range
-the respawn zones should be in the middle of the checkpoints to reduce camera time
-the commented lines get rid of the camera flights but only once
-Edit: added messages and teleport works almost instantly now
Code:
 
PLAYER_PED p1 = (125.0, 129.5, 255.0) 5 270

COUNTER  game = 0
COUNTER sz11=1
COUNTER sz12=1
CAR_DATA startcar1

COUNTER display11=1
COUNTER display21=1
COUNTER display31=1

LEVELSTART
WHILE (game = 0)

IF (CHECK_CHARACTER_HEALTH(p1, 0))   
   IF ((runonce=1) OR (IS_CAR_WRECKED ( startcar1 )))
      startcar1 = CREATE_CAR (125.0, 128.5) 28 180 WBTWIN END
   ENDIF
   IF ( LOCATE_CHARACTER_ANY_MEANS ( p1 , 126.5 , 136.5 , 2.0 , 5.0 , 5.0 ))
      IF (display31=1)
         SET display31=0
         DISPLAY_MESSAGE ( 5501 )
      ENDIF
      ADD_SCORE  ( p1 , 999999 )
   ELSE
      SET display31=1
   ENDIF
   
   //Respawnpoints
   IF ( LOCATE_CHARACTER_ANY_MEANS ( p1, 111.5, 104.5, 1.0, 2.0, 2.0))
      IF (sz11=1)
         IF (display11=1)
            SET display11=0
            DISPLAY_MESSAGE ( 5504 )
         ENDIF
         IF (NOT(HAS_CHARACTER_DIED(p1)))
            WARP_FROM_CAR_TO_POINT ( p1, 125.0, 129.5, 2.0, 180 )
            SET display11=1            
         ENDIF
      ENDIF
      IF (sz21=1)
         IF (NOT(HAS_CHARACTER_DIED(p1)))
            WARP_FROM_CAR_TO_POINT ( p1, 76.0, 42.5, 4.0, 180 )
         ENDIF
      ENDIF
   ENDIF
   IF ( LOCATE_CHARACTER_ANY_MEANS ( p1, 76.0, 40.5, 4.0, 5.0, 3.0))
      IF (display21=1)
         SET display21=0
         DISPLAY_MESSAGE ( 5503 )
      ENDIF
      SET sz11=0
      SET sz21=1   
   ELSE
      SET display21=1
   ENDIF
ENDIF

ENDWHILE
LEVELEND

_________________
yur sa'nok ngeyä


Top
 Profile  
 
 Post subject: Re: Code Snippets
PostPosted: Sun Dec 26, 2010 11:37 pm 
Offline
Ped
User avatar

Joined: Thu Dec 16, 2010 11:57 am
Posts: 4
To make flamethrower less strong ( stop char burning )
Code:
IF ( IS_CHAR_ON_FIRE ( p1 ))
       DELAY_HERE ( put here how long will be the char on fire )
       SET_CHAR_INVINCIBLE ( p1 , ON )
       SET_CHAR_INVINCIBLE ( p1 , OFF )
      ENDIF

work PERFECT ON WHILE CYCLE if u put this to WHILE_EXEC it will not work its little bit complicated to set it on while_exec :(


Top
 Profile  
 
 Post subject: Re: Code Snippets
PostPosted: Mon Dec 27, 2010 6:19 pm 
Offline
User avatar

Joined: Sat Dec 26, 2009 11:53 pm
Posts: 964
lock out a bot:
doors are another candidate for "it's not a bug, it's a feature".
Bots cannot walk or drive through doors, even when they are already open. Although this is stupid it can be an advantage because there is no other way to lock out non player characters.

Just create a door with invisible tiles that is always open and bots wont get through it (99% of them). bots can still be pushed through by explosions.
Code:
DECLARE_DOOR_INFO ( 360 , 367 , 2 )
DOOR_DATA door_1 = DOUBLE (58, 66, 4) (59.0, 66.5, 4.0, 2.0, 1.0) TOP 0 ANY_PLAYER CLOSE_WHEN_OPEN_RULE_FAILS 0 FLIP_RIGHT NOT_REVERSED
LEVELSTART
MAKE_DOOR_MANUAL(door_1)
OPEN_DOOR(door_1)

_________________
yur sa'nok ngeyä


Top
 Profile  
 
 Post subject: Re: Code Snippets
PostPosted: Tue Jan 04, 2011 11:06 pm 
Offline

Joined: Sat May 16, 2009 6:14 am
Posts: 852
Location: London, UK
From the DOOR_DATA section of DMA's documentation:
DMA Scripting Document wrote:
If you give the door a <code>close never</code> type, it will stay permanently open & will let anything go through. All other types will only let the 'type' that opened it through, e.g the player, a particular car.

In your code, ANY_PLAYER is the 'type' that opened it. So only they can get through, I guess. There is an ANY_CAR door opening type but there's no ANY_MEANS one.

Setting the door closing type to CLOSE_NEVER would be worth a try, given the quote above.

(EDIT) Welcome, your code be run by a THREAD_TRIGGER at each player's start location. It would contain a WHILE_EXEC which checked the player still existed, then checked if they were on fire, then shortened the flame duration.

Industrial has like 30 threads, for Kill Frenzy and phones and so on. 6 threads plus your main loop should be fine. (Maybe I should give an example, oops.)

_________________
BenMillard's GTA5 Races, Off-Roading and Deathmatches | GTA2 Multiplayer Levels | Mission Code Tutorials | GTA2 YouTube Videos


Top
 Profile  
 
 Post subject: Re: Code Snippets
PostPosted: Thu Feb 17, 2011 7:15 pm 
Offline
User avatar

Joined: Sat Dec 26, 2009 11:53 pm
Posts: 964
Custom death message
Code:
IF ( HAS_CHARACTER_DIED ( p1 )  ) //Player died
   IF ((p1_trg_arena=1) OR (p1_noraceon=1)) //you died in the arena in your car or before getting back in
      SET msg_hurt=3
   ENDIF
ENDIF
//DEATH MESSAGE
IF (msg_hurt>1)
   SET msg_hurt = ( msg_hurt - 1 )
ENDIF
IF (msg_hurt=1)
   SET temp = ( rand / 4 )
   SET temp = ( temp * 4 )
   SET temp= ( rand - temp )
   IF (temp=0)
      DISPLAY_MESSAGE ( 5053 )
   ENDIF
   IF (temp=1)
      DISPLAY_MESSAGE ( 5058 )
   ENDIF
   IF (temp=2)
      DISPLAY_MESSAGE ( 5059 )
   ENDIF
   IF (temp=3)
      DISPLAY_MESSAGE ( 5031 )
   ENDIF
   SET msg_hurt = 0
ENDIF

-everything in while_exec
-rand must be a counter that is increased every cycle and reset on pseudo random situations for seed

_________________
yur sa'nok ngeyä


Last edited by elypter on Sat Feb 19, 2011 1:04 pm, edited 2 times in total.

Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 44 posts ]  Go to page 1, 2, 3  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group