zAndreas -
Grim_ - 16.07.2010
zAndreas
This include does not work. Do not bother downloading
Introduction
Since the last time I've checked, MapAndreas still uses a lot of memory when being run, which I would imagine people wouldn't like. So in order to solve my problems with the plugin, I've created this simple script to allow me to do something similar to MapAndreas, but less resourceful.
How it works
The idea behind this script is pretty basic, and I'm surprised no one has come up with this idea before. It simply connects a NPC to your server when your script starts. Then when you call a function to find the Z coordinate of a position, it sets that NPC to that spot, while finding the Z.
Functions & Examples
The current version has the following functions:
pawn Код:
zAndreas_Init();
zAndreas_OnPlayerSpawn(playerid);
Float:ReturnPlayerZ(playerid);
Float:ReturnZFromXY(Float:x, Float:y);
This is an example script to make a hydra drop a bomb:
pawn Код:
#include <a_samp>
#include <zAndreas>
new pObject[MAX_PLAYERS];
new pTimer[MAX_PLAYERS];
public OnFilterScriptInit()
{
zAndreas_Init();
return 1;
}
public OnPlayerSpawn(playerid)
{
zAndreas_OnPlayerSpawn(playerid);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/b", true))
{
if(!IsPlayerInAnyVehicle(playerid)) return 1;
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 520)
{
new Float:outcome, Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
outcome = ReturnPlayerZ(playerid); // Returns the Z below player
pTimer[playerid] = SetTimerEx("Bomb", 1000, true, "if", playerid, outcome);
pObject[playerid] = CreateObject(3786, X, Y, Z-5, 0.00, 0.00, 0.00);
// Math time :'(
outcome = (outcome + Z) / 2; // Returning half the distance form the ground to the hydra
outcome = outcome * 2; // Returning the full length of the distance from ground to hydra
MoveObject(pObject[playerid], X, Y, Z-outcome, 20.0); // Move the object towards the ground
}
return 1;
}
return 0;
}
forward Bomb(playerid, Float:z);
public Bomb(playerid, Float:z)
{
new Float:Pos[3];
GetObjectPos(pObject[playerid], Pos[0], Pos[1], Pos[2]);
if(Pos[2] <= z)
{
CreateExplosion(Pos[0], Pos[1], z, 7, 10.0);
DestroyObject(pObject[playerid]);
KillTimer(pObject[playerid]);
}
return 1;
}
How to Install
1. Download the .rar file
2. Extract the files
3. Move the files into the correct directories in your scripting folders
4. Add this into the script you would like to use this:
5. Add the following lines into the following callbacks:
pawn Код:
zAndreas_Init(); // OnGameModeInit / OnFilterScriptInit
zAndreas_OnPlayerSpawn(playerid); // OnPlayerSpawn(playerid)
6. Enjoy
Download
zAndreas - v1.0
Re: zAndreas -
Toni - 16.07.2010
Wow, great job Grim, switching to it right away.
Re: zAndreas -
Grim_ - 16.07.2010
Thanks Toni.
Everyone who has tested said it has worked correctly, so I'm relying on their words. If you find any bugs, please tell me.
Re: zAndreas -
Toni - 16.07.2010
ok
offtopic: I'm about to get 500 posts xD
Re: zAndreas - [L3th4l] - 16.07.2010
Nice dude, i also found MapAndreas using alot of memory, i'll go test this and let you know
Re: zAndreas - [03]Garsino - 16.07.2010
Nice work, Grim_
Re: zAndreas -
Carlton - 16.07.2010
Nice work. It's genius the way you did this, using a NPC to find the Z coordinate. I'm impressed.
Re: zAndreas -
Grim_ - 16.07.2010
Thank you Carlton, it means a lot.
Re: zAndreas -
Trooper[Y] - 16.07.2010
Pastebin would be nice...
And i already tried this,
but for me it didnt work (dunno why, but i gave it up)
Nice thing,
really good work
//edit:
Where the **** is my signature ?
Re: zAndreas -
Young_Monaays - 17.07.2010
Quote:
Originally Posted by Trooper[Y]
Pastebin would be nice...
//edit:
Where the **** is my signature ?
|
FAILLL BOOOOATTTT.... TOOOOT TOOOOOT.
Epicness ftw.
(BTW GGRREEEAAAT SCRIPPPT, WORKED 100%, THANKS BROOO!!!
)