SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 15/02/2017, 04:38 AM   #1
SoFahim
Gangsta
 
SoFahim's Avatar
 
Join Date: May 2015
Location: Bangladesh.
Posts: 879
Reputation: 86
Default [Q/A] texture method

Best method for texture scripting

Method 1 :
PHP Code:
SetObjectMeterial(CreateObject(),....);
SetObjectMeterial(CreateObject(),....); 

Method 2 :
PHP Code:
new Texture;
Texture =CreateObject();
SetObjectMeterial(Texture,...);
Texture =CreateObject();
SetObjectMeterial(Texture,...); 


Method 3 :
PHP Code:
new Texture[2];
Texture[0] =CreateObject();
SetObjectMeterial(Texture[0],...);
Texture[1] =CreateObject();
SetObjectMeterial(Texture[1],...); 


Please let me know, which one will be good and why?
__________________
Lead Developer & Mapping manager of SARP

You can contact me at Discord, my ID: Gold#8839 available for paid works
Quote:
SoFahim is offline   Reply With Quote
Old 15/02/2017, 04:55 AM   #2
DRIFT_HUNTER
High-roller
 
Join Date: Oct 2009
Posts: 2,151
Reputation: 215
Default Re: [Q/A] texture method

With first method you can change only one texture on a single object.
Second will create only one variable so it will be faster than third which is allocating more variables.

So at the end best method is second one, but it makes no difference as all three works and there is no performance impact (you create objects only at startup).
DRIFT_HUNTER is offline   Reply With Quote
Old 15/02/2017, 06:59 AM   #3
PrO.GameR
Gangsta
 
PrO.GameR's Avatar
 
Join Date: Oct 2012
Posts: 694
Reputation: 121
Default Re: [Q/A] texture method

The thing is, whatever memory it'd use it's still created locally, which means it's (usually) part of the OnGmInit and only done once and doesn't really matter, so I'd suggest you to use whatever generated code a map editor gives you.
__________________
Blueberry Prison Roleplay will be back soon!
Follow the forums for more information about opening day.

Forums
PrO.GameR is offline   Reply With Quote
Old 15/02/2017, 07:20 AM   #4
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,773
Reputation: 858
Default Re: [Q/A] texture method

All the 3 methods have their own uses.

If you just want to set the texture once: Method 1
If you want to set the texture multiple times and while creating the object only: Method 2
If you want to change textures for specific objects later on: Method 3

You can use all the methods together according to your need.
__________________

Follow me on Github: Donate on Paypal:

Gammix is offline   Reply With Quote
Old 15/02/2017, 12:42 PM   #5
SoFahim
Gangsta
 
SoFahim's Avatar
 
Join Date: May 2015
Location: Bangladesh.
Posts: 879
Reputation: 86
Default Re: [Q/A] texture method

Well, I mostly use method 2. Just for making myself sure, I asked it here.
__________________
Lead Developer & Mapping manager of SARP

You can contact me at Discord, my ID: Gold#8839 available for paid works
Quote:
SoFahim is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] 420 Texture Viewer and ALL SA texture Array Pottus Filterscripts 45 11/02/2017 01:48 PM
[HELP] Object Texture Problem on Texture Studio MarleyBanks Scripting Help 1 28/11/2015 10:45 AM
[FilterScript] Texture Studio - Texture your maps Pottus Filterscripts 462 20/07/2015 10:35 PM
[HELP] What is the best method to do this. [BKR]LUCAGRABACR Help Archive 1 10/03/2011 09:36 AM


All times are GMT. The time now is 08:13 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.