16.07.2010, 01:35
(
Последний раз редактировалось Grim_; 19.07.2010 в 12:07.
)
zAndreas
This include does not work. Do not bother downloading
IntroductionSince 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);
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;
}
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:
pawn Код:
#include <zAndreas>
pawn Код:
zAndreas_Init(); // OnGameModeInit / OnFilterScriptInit
zAndreas_OnPlayerSpawn(playerid); // OnPlayerSpawn(playerid)
Download
zAndreas - v1.0