Quantcast

Jump to content

» «
Photo

Creating Objects

14 replies to this topic
rhedge004
  • rhedge004

    Player Hater

  • Members
  • Joined: 08 Aug 2009

#1

Posted 12 April 2012 - 06:39 AM

Hey guys can i ask how to create objects or spawn objects in front of CJ..
For example i want to spawn a box or tree in front of CJ whats the code??
Im new at coding so please help me.. biggrin.gif

Deji
  • Deji

    Coding like a Rockstar!

  • Feroci Racing
  • Joined: 24 Dec 2007
  • None

#2

Posted 12 April 2012 - 08:45 AM

http://gtag.gtagamin...php?opcode=0107

ZAZ
  • ZAZ

    Kernlochbohrer

  • Members
  • Joined: 10 Jan 2005
  • European-Union

#3

Posted 12 April 2012 - 08:48 AM

read tutorials, start at the pinned topic: III Coding Directory

MichaelKnight1
  • MichaelKnight1

    Snitch

  • BUSTED!
  • Joined: 24 Mar 2012

#4

Posted 12 April 2012 - 09:36 AM

QUOTE (rhedge004 @ Thursday, Apr 12 2012, 06:39)
Hey guys can i ask how to create objects or spawn objects in front of CJ..
For example i want to spawn a box or tree in front of CJ whats the code??
Im new at coding so please help me.. biggrin.gif

Not feasible, we will help you now and then after that ?? . you must Studying the application of The educational .
QUOTE

how to create objects or spawn objects in front of CJ

From your words mean to put Object in front of CJ ok so .
CODE

04C4: store_coords_to 3@ 4@ 5@ from_actor $PLAYER_ACTOR with_offset 2.0 2.0 0.0

These coordinates is not with SA Place Manager . . .
You can use 3ds Max or Zmodeler .
ok Then Create Object At 3@ - 4@ - 5@
CODE

0107: 6@ = create_object #AD_FLATDOOR at 3@ 4@ 5@

warning ; not using Global variables in cleo scripts, it can cause bugs or crashes!





Deji
  • Deji

    Coding like a Rockstar!

  • Feroci Racing
  • Joined: 24 Dec 2007
  • None

#5

Posted 12 April 2012 - 10:23 AM

QUOTE (MichaelKnight1 @ Thursday, Apr 12 2012, 09:36)
Not feasible, we will help you now and then  after that ?? . you must Studying the application of The educational .

You should practise what you preach wink.gif

وهذا هو منتدى باللغة الإنجليزية فقط!

ChopTheDog.
  • ChopTheDog.

    War. War never changes.

  • Members
  • Joined: 31 May 2010
  • None

#6

Posted 12 April 2012 - 10:26 AM

It's pretty simple, although I myself haven't done this before with trees and such, I'm going with common sense.

Firstly, Collect the ID of the model you want to spawn since I'm assuming there isn't a model name for ' tree ' in sanny builder, A little research will find you your ID

To load the model (Using the ID you collected) use this code:

CODE
0247: load_model #WBDYG2


Replace #WBDYG2 with your model ID number

Now, You need to collect the coords (Coordinates) of CJ with an offset, The offset it used to collect coordinates infront, behind and to the side of him.

Use this code to collect the coords:

CODE
04C4: store_coords_to $1 $2 $3 from_actor $PLAYER_ACTOR with_offset 1.0 3.0 1.0


$1 $2 and $3 are global variables, Although everybody advises not to use them I have always used them and had no problems

$PLAYER_ACTOR - Self explanatory really, This is CJ

1.0 3.0 1.0 - These are the offset coords, X, Y and Z

Using the 'Create' opcode below you can spawn your object using the coords you collected:

CODE
0107: $Myobject = create_object #AD_FLATDOOR at $1 $2 $3


Replace #AD_FLATDOOR with your model number and your code should now spawn your object infront of CJ

The full code? Oh yes:

CODE
0247: load_model #WBDYG2
04C4: store_coords_to $1 $2 $3 from_actor $PLAYER_ACTOR with_offset 1.0 3.0 1.0
0107: $Myobject = create_object #AD_FLATDOOR at $1 $2 $3


Hope this helped and good luck, Obviously the code I gave you isn't fully completed, Research and use common sense, you'll be a coding pro in no time!

Deji
  • Deji

    Coding like a Rockstar!

  • Feroci Racing
  • Joined: 24 Dec 2007
  • None

#7

Posted 12 April 2012 - 10:31 AM

QUOTE (The_Sorrow @ Thursday, Apr 12 2012, 10:26)
CODE
04C4: store_coords_to $1 $2 $3 from_actor $PLAYER_ACTOR with_offset 1.0 3.0 1.0


$1 $2 and $3 are global variables, Although everybody advises not to use them I have always used them and had no problems

If someone tells you not to jump off a cliff into the sea because there are sharks at the bottom, will you still jump in just because they weren't there to tear you apart the first time? tounge2.gif

ChopTheDog.
  • ChopTheDog.

    War. War never changes.

  • Members
  • Joined: 31 May 2010
  • None

#8

Posted 12 April 2012 - 10:32 AM

QUOTE (Deji @ Thursday, Apr 12 2012, 10:31)
QUOTE (The_Sorrow @ Thursday, Apr 12 2012, 10:26)
CODE
04C4: store_coords_to $1 $2 $3 from_actor $PLAYER_ACTOR with_offset 1.0 3.0 1.0


$1 $2 and $3 are global variables, Although everybody advises not to use them I have always used them and had no problems

If someone tells you not to jump off a cliff into the sea because there are sharks at the bottom, will you still jump in just because they weren't there to tear you apart the first time? tounge2.gif

Nah, but this is coding related, whats the worst that can happen? wink.gif

Deji
  • Deji

    Coding like a Rockstar!

  • Feroci Racing
  • Joined: 24 Dec 2007
  • None

#9

Posted 12 April 2012 - 10:39 AM

QUOTE (The_Sorrow @ Thursday, Apr 12 2012, 10:32)
QUOTE (Deji @ Thursday, Apr 12 2012, 10:31)
QUOTE (The_Sorrow @ Thursday, Apr 12 2012, 10:26)
CODE
04C4: store_coords_to $1 $2 $3 from_actor $PLAYER_ACTOR with_offset 1.0 3.0 1.0


$1 $2 and $3 are global variables, Although everybody advises not to use them I have always used them and had no problems

If someone tells you not to jump off a cliff into the sea because there are sharks at the bottom, will you still jump in just because they weren't there to tear you apart the first time? tounge2.gif

Nah, but this is coding related, whats the worst that can happen? wink.gif

Crashes (for which there are many types), bugs, conflicts, computer explosions and inoperability.

I always check CLEO scripts I download for crappiness like bad use of global variables. If the mod is bad, I don't use it. So there's another scenario, people get sick of using scripts that cause bugs and crashes. You could loose the interest of impatient users and as a developer, you should always assume the end-user is dumb and ill-tempered.

And sure, you have the freedom to jump into the sea of sharks, I just beg you not to encourage others to do the same.

ChopTheDog.
  • ChopTheDog.

    War. War never changes.

  • Members
  • Joined: 31 May 2010
  • None

#10

Posted 12 April 2012 - 10:50 AM

QUOTE (Deji @ Thursday, Apr 12 2012, 10:39)
QUOTE (The_Sorrow @ Thursday, Apr 12 2012, 10:32)
QUOTE (Deji @ Thursday, Apr 12 2012, 10:31)
QUOTE (The_Sorrow @ Thursday, Apr 12 2012, 10:26)
CODE
04C4: store_coords_to $1 $2 $3 from_actor $PLAYER_ACTOR with_offset 1.0 3.0 1.0


$1 $2 and $3 are global variables, Although everybody advises not to use them I have always used them and had no problems

If someone tells you not to jump off a cliff into the sea because there are sharks at the bottom, will you still jump in just because they weren't there to tear you apart the first time? tounge2.gif

Nah, but this is coding related, whats the worst that can happen? wink.gif

Crashes (for which there are many types), bugs, conflicts, computer explosions and inoperability.

I always check CLEO scripts I download for crappiness like bad use of global variables. If the mod is bad, I don't use it. So there's another scenario, people get sick of using scripts that cause bugs and crashes. You could loose the interest of impatient users and as a developer, you should always assume the end-user is dumb and ill-tempered.

And sure, you have the freedom to jump into the sea of sharks, I just beg you not to encourage others to do the same.

Do sharks interest you?

OT: Scroll up for the solution to your problem!

MichaelKnight1
  • MichaelKnight1

    Snitch

  • BUSTED!
  • Joined: 24 Mar 2012

#11

Posted 12 April 2012 - 11:31 AM

I advise you to hold Your Computer And Throw it on the ground ok , Why use the Arabic language and from & What do you mean to the

Use brotherly advice

Looooooooooooooooooooool xDD

ZAZ
  • ZAZ

    Kernlochbohrer

  • Members
  • Joined: 10 Jan 2005
  • European-Union

#12

Posted 12 April 2012 - 12:28 PM

QUOTE (The_Sorrow @ Thursday, Apr 12 2012, 10:50)
QUOTE (Deji @ Thursday, Apr 12 2012, 10:39)
QUOTE (The_Sorrow @ Thursday, Apr 12 2012, 10:32)
QUOTE (Deji @ Thursday, Apr 12 2012, 10:31)
QUOTE (The_Sorrow @ Thursday, Apr 12 2012, 10:26)
CODE
04C4: store_coords_to $1 $2 $3 from_actor $PLAYER_ACTOR with_offset 1.0 3.0 1.0


$1 $2 and $3 are global variables, Although everybody advises not to use them I have always used them and had no problems

If someone tells you not to jump off a cliff into the sea because there are sharks at the bottom, will you still jump in just because they weren't there to tear you apart the first time? tounge2.gif

Nah, but this is coding related, whats the worst that can happen? wink.gif

Crashes (for which there are many types), bugs, conflicts, computer explosions and inoperability.

I always check CLEO scripts I download for crappiness like bad use of global variables. If the mod is bad, I don't use it. So there's another scenario, people get sick of using scripts that cause bugs and crashes. You could loose the interest of impatient users and as a developer, you should always assume the end-user is dumb and ill-tempered.

And sure, you have the freedom to jump into the sea of sharks, I just beg you not to encourage others to do the same.

Do sharks interest you?

OT: Scroll up for the solution to your problem!

I cofirm to Deji agian and again.
I often could experienced that gloabals of cleo corrupt globals of main.
As i converted the carmod externscript as cleo which have a lot of globals i got heavy bugs and sometimes crashes
So i converted all globals in locals and got a fine working script
this script is now a part of my Pimp My Car mod

Just a few globals in cleoscripts seems to don't have an effect unless while running a mission at same times which use a global

I also sceptical about the globals of Sanny Builder 3\data\sa\CustomVariables.ini
I tested one of these globals in a cleo mission to display a status bar
I went into ammunation while status bar was on and got a failure in the meue text

So please don't teach, use globals
For cleo we have extra opcodes
0AB3: and 0AB4:
The expression var together with a number, <var><space><number> is builing the Special Global Cleo Variable
CODE
0AB3: var 0 = 10

or
CODE
0006: 13@ =  10  // integer values
0AB3: var 0 = 13@

and
CODE
0AB4: 0@= var 0

to get then stored value into your script needs to submit into a local:
CODE
0AB4: 13@ = var 44
if
0039:   13@ ==  1  // integer values
004D: jump_if_false @nextlabel

Bad.boy!
  • Bad.boy!

    SA modder

  • Feroci Racing
  • Joined: 20 Jun 2010
  • None

#13

Posted 12 April 2012 - 01:30 PM

Don't forget to check the player angle, or the object can spawn behind, left and right from you.
IF you are using globals don't use $2 and $3 because:
CODE
$2 = $PLAYER_CHAR
$3 = $PLAYER_ACTOR

Deji
  • Deji

    Coding like a Rockstar!

  • Feroci Racing
  • Joined: 24 Dec 2007
  • None

#14

Posted 12 April 2012 - 02:58 PM

QUOTE (MichaelKnight1 @ Thursday, Apr 12 2012, 11:31)
I advise you to hold Your Computer And Throw it on the ground ok , Why use the Arabic language and from & What do you mean to the

Use brotherly advice

Looooooooooooooooooooool xDD

Calm down, Ahmed. I don't want no trouble.

BnB
  • BnB

    Better days

  • The Yardies
  • Joined: 28 Jun 2010
  • Serbia

#15

Posted 12 April 2012 - 04:02 PM

QUOTE (MichaelKnight1 @ Thursday, Apr 12 2012, 11:36)
QUOTE (rhedge004 @ Thursday, Apr 12 2012, 06:39)
Hey guys can i ask how to create objects or spawn objects in front of CJ..
For example i want to spawn a box or tree in front of CJ whats the code??
Im new at coding so please help me.. biggrin.gif

Not feasible, we will help you now and then after that ?? . you must Studying the application of The educational .
QUOTE

how to create objects or spawn objects in front of CJ

From your words mean to put Object in front of CJ ok so .
CODE

04C4: store_coords_to 3@ 4@ 5@ from_actor $PLAYER_ACTOR with_offset 2.0 2.0 0.0

These coordinates is not with SA Place Manager . . .
You can use 3ds Max or Zmodeler .
ok Then Create Object At 3@ - 4@ - 5@
CODE

0107: 6@ = create_object #AD_FLATDOOR at 3@ 4@ 5@

warning ; not using Global variables in cleo scripts, it can cause bugs or crashes!

I must say this post was no helpful at all, in fact it will confuse the OP. So, please stay out of this topic.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users