SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 01/08/2011, 12:50 AM   #1
RyDeR`
High-roller
 
RyDeR`'s Avatar
 
Join Date: Feb 2009
Location: Belgium
Posts: 2,929
Reputation: 696
Default MapAndreas Include

Foreword

I love the MapAndreas plugin, but I find so unfortunate that it uses ~70 MB's of RAM memory, so I started browsing the topic and found out that you can actually get the same results using fseek by setting the position indicator of the file using a small calculation instead of allocating the whole map into the memory.

Features

This include has exactly the same features as the MapAndreas plugin and is as accurate - there's simply no difference in terms of functioning between them:

MapAndreas PluginMapAndreas Include
Memory usage~70 MB RAMNothing*
AccuracyEXACTLY the same accuracy as the plugin
PerformanceThe plugin is really fast (because the data is allocated in the memory first and has the C++ performance advantage)This include is slower than the plugin (obviously because we're using fseek and read all time again plus we don't have the C++ performance advantage in this case)
Initialize timeTakes some time to allocate the memory (~5 seconds)No waiting needed - immediately ready for use

* Although every script needs some memory (depending what you're using and how much) to execute. I assume this will use a couple of hundred kilobytes.

Function(s)

We have only one function:
pawn Code:
stock Float: GetPointZPos(const Float: fX, const Float: fY, &Float: fZ = 0.0);
It returns the result and stores it in fZ (if variable defined).

Example(s)

Here are some basic examples:
pawn Code:
printf("The Z-coordinate of X = 2033.55 | Y = 1007.73 is Z = %.02f", GetPointZPos(2033.55, 1007.73));
Or you can just do it this way:
pawn Code:
new
    Float: fZ
;
GetPointZPos(1254.65, -554.55, fZ);
printf("The Z-coordinate of X = 1254.65 | Y = -554.55 is Z = %.02f", fZ);
Results:
Code:
The Z-coordinate of X = 2033.55 | Y = 1007.73 is Z = 9.81
The Z-coordinate of X = 1254.65 | Y = -554.55 is Z = 67.48
Notes

- Credits to Kalcor for his MapAndreas plugin.
- Credits to De[M]oN who posted a C++ fseek example in there.

Download

MapAndreas.inc
SAfull.hmap
__________________

Sup?

Last edited by RyDeR`; 06/04/2012 at 10:57 AM.
RyDeR` is offline   Reply With Quote
Old 01/08/2011, 12:54 AM   #2
iPLEOMAX
High-roller
 
iPLEOMAX's Avatar
 
Join Date: Mar 2011
Location: AE
Posts: 1,251
Reputation: 744
Thumbs up Re: MapAndreas Include

Awesome work Ryder... You make very useful things everytime.
Thanks.
__________________
Goodbye SA-MP.
iPLEOMAX is offline   Reply With Quote
Old 01/08/2011, 01:00 AM   #3
MrDeath537
High-roller
 
Join Date: Nov 2009
Location: Argentina
Posts: 1,959
Reputation: 29
Default Re: MapAndreas Include

inb4 I'll learn to use fseek.
Nice work RyDeR

EDIT 1: I don't understand how to use fseek. xD
__________________
Sometimes I return.
MrDeath537 is offline   Reply With Quote
Old 01/08/2011, 01:06 AM   #4
Donya
Gangsta
 
Join Date: Mar 2011
Posts: 715
Reputation: 33
Default Re: MapAndreas Include

Wow! nice, this will help ALOT of people!
__________________
[FilterScript]Exception 0xC0000005 at 0x7F120E Protection | OnVehicleMod monitoring. Now Full Protection!

I'm sorry for what was posted earlier, I was hacked.

Last edited by Donya; 01/08/2011 at 06:05 PM.
Donya is offline   Reply With Quote
Old 01/08/2011, 01:27 AM   #5
Toni
High-roller
 
Toni's Avatar
 
Join Date: Aug 2009
Location: United States
Posts: 1,464
Reputation: 156
Default Re: MapAndreas Include

Great job on this include! I looked at your code and wow that look's fairly advanced lol.
__________________
Toni is offline   Reply With Quote
Old 01/08/2011, 01:30 AM   #6
SlashPT
High-roller
 
SlashPT's Avatar
 
Join Date: Sep 2009
Location: Hell
Posts: 1,973
Reputation: 116
Default Re: MapAndreas Include

That's what i call awesome shit

- Good work Ryder
__________________

Zh3r0Jansish
SlashPT is offline   Reply With Quote
Old 01/08/2011, 01:53 AM   #7
D3IMON
Big Clucker
 
Join Date: Jul 2011
Location: Santiago,Chile
Posts: 155
Reputation: 0
Default Respuesta: MapAndreas Include

I like good work
D3IMON is offline   Reply With Quote
Old 01/08/2011, 02:06 AM   #8
[LoD]Hauke
Little Clucker
 
Join Date: Jan 2010
Posts: 45
Reputation: 42
Default Re: MapAndreas Include

Nice!
i like it!
[LoD]Hauke is offline   Reply With Quote
Old 01/08/2011, 08:07 AM   #9
RyDeR`
High-roller
 
RyDeR`'s Avatar
 
Join Date: Feb 2009
Location: Belgium
Posts: 2,929
Reputation: 696
Default Re: MapAndreas Include

Quote:
Originally Posted by MrDeath537 View Post
inb4 I'll learn to use fseek.
Nice work RyDeR

EDIT 1: I don't understand how to use fseek. xD
"fseek" is just setting the position indicator from a specific file handle (first parameter) by adding an offset (position parameter) to a reference position specified by origin (whence parameter).

EDIT:
Quote:
Originally Posted by Donya View Post
Wow! nice, this will help ALOT of people!

ohwell.

<results>

Well, that is of choice on my slow pc, I'm show it won't be that slow on a real host
Yes - Probably your PC because it's not really correct.
__________________

Sup?
RyDeR` is offline   Reply With Quote
Old 01/08/2011, 09:01 AM   #10
wups
High-roller
 
wups's Avatar
 
Join Date: Apr 2010
Location: Lithuania
Posts: 1,215
Reputation: 141
Default Re: MapAndreas Include

I can't think up much use with this speed.
wups 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] MapAndreas plugin v1.0 beta Kalcor Plugin Development 262 06/09/2017 09:05 PM
[FilterScript] [FS] Bomber script / MapAndreas usage example krisk Filterscripts 32 11/07/2011 11:02 AM
Need <mapandreas> include newnewnew Help Archive 2 12/01/2011 07:29 PM
mapandreas.dll problem ? Rocky Balboa Help Archive 6 11/07/2010 05:45 PM


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


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