SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 28/07/2012, 05:16 PM   #1
Xentiarox
Big Clucker
 
Xentiarox's Avatar
 
Join Date: Jun 2012
Location: Tilburg, NL
Posts: 116
Reputation: 30
Default Very good plugin suggestion (for scripters) and easy to make for the Plugin Developers!

I was working in VB.NET and I came up with an idea to make a plugin. Something like "ReDim'.

ReDim in VB.NET changes the size of an array on-the-fly.
So, what I suggest to someone is to create this function:
Code:
native ReNew(array[],MaxSize=1,bool:PreserveData=true);

and the usage would be like this:
Code:
new bool:Respawned[2] = {false,...};
new AOVOS = GetAmountOfVehiclesOnServer();
ReNew(Respawned,AOVOS ,false);
for(new i = 0; i < AOVOS; ++i)
{
        SetVehicleToRespawn(i);
        Respawned[i] = true;
}

This is not the best example I can come up with but there would be situations where it would be really handy if a array could be resized.

(And this can save up amx size alot)
__________________
Professional scripting for low price. PM for details.
Pure Nederlandse DM

[img]http://*******/aYXdL[/img]
Xentiarox is offline   Reply With Quote
Old 28/07/2012, 05:30 PM   #2
Macluawn
Gangsta
 
Macluawn's Avatar
 
Join Date: Aug 2010
Location: Latvia
Posts: 640
Reputation: 78
Default Re: Very good plugin suggestion (for scripters) and easy to make for the Plugin Developers!

  1. Wrong section;
  2. there already is a dynamic memory plugin (with vector and map support);
  3. few extra kb wont kill anyone. I doubt anyone is using a server from 1970's where memory is 1mb.
Macluawn is offline   Reply With Quote
Old 28/07/2012, 05:43 PM   #3
Xentiarox
Big Clucker
 
Xentiarox's Avatar
 
Join Date: Jun 2012
Location: Tilburg, NL
Posts: 116
Reputation: 30
Default Re: Very good plugin suggestion (for scripters) and easy to make for the Plugin Developers!

Quote:
Originally Posted by Macluawn View Post
  1. Wrong section;
  2. there already is a dynamic memory plugin (with vector and map support);
  3. few extra kb wont kill anyone. I doubt anyone is using a server from 1970's where memory is 1mb.
Ofcourse there is a vector plugin but sometimes, let's assume that you have to pass an array to a function, then if you use vectors you have to create an additional array to get the array from the vector.
Also this sections is for plugins discussions too so sorry but this is the right section.

Proof:
http://forum.sa-mp.com/showthread.php?t=356376
http://forum.sa-mp.com/showthread.php?t=323608
http://forum.sa-mp.com/showthread.php?t=281769
http://forum.sa-mp.com/showthread.php?t=314452
http://forum.sa-mp.com/showthread.php?t=304803
http://forum.sa-mp.com/showthread.php?t=295816
http://forum.sa-mp.com/showthread.php?t=289999
etc..
__________________
Professional scripting for low price. PM for details.
Pure Nederlandse DM

[img]http://*******/aYXdL[/img]
Xentiarox is offline   Reply With Quote
Old 28/07/2012, 06:41 PM   #4
RussellK
Little Clucker
 
RussellK's Avatar
 
Join Date: Nov 2011
Location: Germany / UK
Posts: 9
Reputation: 0
Default Re: Very good plugin suggestion (for scripters) and easy to make for the Plugin Developers!

Memory in Pawn is statically allocated and already included in the compiled .amx file. Resizing arrays during runtime will prove to be incredibly hard, if it's possible at all, for a relatively minor gain. You really should consider going for plugins such as the vector one.
__________________
Time is never wasted when you're wasted all the time.
RussellK is offline   Reply With Quote
Old 29/07/2012, 06:30 PM   #5
Xentiarox
Big Clucker
 
Xentiarox's Avatar
 
Join Date: Jun 2012
Location: Tilburg, NL
Posts: 116
Reputation: 30
Default Re: Very good plugin suggestion (for scripters) and easy to make for the Plugin Developers!

Quote:
Originally Posted by RussellK View Post
Memory in Pawn is statically allocated and already included in the compiled .amx file. Resizing arrays during runtime will prove to be incredibly hard, if it's possible at all, for a relatively minor gain. You really should consider going for plugins such as the vector one.
I always use it, weel this was just a suggestion.

But when I think about it: Hey the .amx doesn't modify itself, or does it? It has to have some RAM to store the values in?! :O else it would be incredibly slow, RAM VS HDD is NO MATCH FOR RAM :P
I would like an answer from somebody who actually knows the pawn VM Very good and how the arrays work there :$
__________________
Professional scripting for low price. PM for details.
Pure Nederlandse DM

[img]http://*******/aYXdL[/img]
Xentiarox is offline   Reply With Quote
Old 29/07/2012, 11:48 PM   #6
RussellK
Little Clucker
 
RussellK's Avatar
 
Join Date: Nov 2011
Location: Germany / UK
Posts: 9
Reputation: 0
Default Re: Very good plugin suggestion (for scripters) and easy to make for the Plugin Developers!

Quote:
Originally Posted by Xentiarox View Post
I always use it, weel this was just a suggestion.
But when I think about it: Hey the .amx doesn't modify itself, or does it? It has to have some RAM to store the values in?! :O else it would be incredibly slow, RAM VS HDD is NO MATCH FOR RAM :P
I would like an answer from somebody who actually knows the pawn VM Very good and how the arrays work there :$
An .amx file will be loaded in memory in its entirety, and be ran from there. The file header contains the size of the DATA section, which is what will be allocated (unless overlays are being used, but it comes down to roughly the same idea). Your code will refer to array sections directly as well, making it hard to relocate them.
__________________
Time is never wasted when you're wasted all the time.
RussellK 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
PLUGIN DEVELOPERS: Please read. michael2572 Plugin Development 2 05/08/2010 11:05 AM


All times are GMT. The time now is 12:36 AM.


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