25.12.2010, 16:08
(
Последний раз редактировалось sansko; 29.12.2010 в 23:19.
Причина: found a bug
)
This is my first predator missle release
its still buggy but it will be fixed in 1.0 and then it also will use mapandreas
controls:
/predator = gives you control over the missle placing
key left = let the missle go left
key right = let the missle go right
key up = let the missle go up
key down = let the missle go down
key fire = launch the missle
download is as attachment
edit: v1 is now live and uses map andreas
edit2: this code is the fixed version but will not be uploaded before it is tested
its still buggy but it will be fixed in 1.0 and then it also will use mapandreas
controls:
/predator = gives you control over the missle placing
key left = let the missle go left
key right = let the missle go right
key up = let the missle go up
key down = let the missle go down
key fire = launch the missle
download is as attachment
edit: v1 is now live and uses map andreas
edit2: this code is the fixed version but will not be uploaded before it is tested
pawn Код:
//------------------------------
//Predator missle V1.0.01 by sansko
//------------------------------
#include <a_samp>
#include <mapandreas>
//------------------------------
new missle;
#define speed 15
forward movemissle(playerid);
public OnFilterScriptInit()
{
MapAndreas_Init(MAP_ANDREAS_MODE_FULL);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/predator", cmdtext, true, 10) == 0)
{
new Float:a, Float:b, Float:c ;
new Float:f ;
GetPlayerPos(playerid, a, b, c);
MapAndreas_FindZ_For2DCoord(a,b,f);
missle = CreateObject(3786, a, b, f+50, 0, 270, 0, 100);
SetPlayerCameraPos(playerid, a, b, f+60);
SetPlayerCameraLookAt(playerid, a, b, f);
SetPVarInt(playerid, "mc", 1);
SetTimer("movemissle", 100, true);
TogglePlayerControllable(playerid, 0);
return 1;
}
if (strcmp("/camreset", cmdtext, true, 10) == 0)
{
SetCameraBehindPlayer(playerid);
SetPVarInt(playerid, "mc", 0);
TogglePlayerControllable(playerid, 1);
KillTimer("movemissle");
return 1;
}
return 0;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_FIRE)
{
if(GetPVarInt(playerid, "mc") == 1)
{
new Float:j, Float:k, Float:l;
new Float:m, Float:n, Float:o;
new Float:p;
GetPlayerPos(playerid, j, k, l);
GetObjectPos(missle, m, n, o);
MapAndreas_FindZ_For2DCoord(m,n,p);
MoveObject(missle, m, n, p, speed);
SetCameraBehindPlayer(playerid);
SetPVarInt(playerid, "mc", 0);
TogglePlayerControllable(playerid, 1);
KillTimer("movemissle");
return 1;
}
}
return 0;
}
public OnObjectMoved(objectid)
{
if(objectid == missle)
{
new Float:p, Float:q, Float:r, Float:s;
GetObjectPos(missle, p, q, r);
MapAndreas_FindZ_For2DCoord(p,q,s);
DestroyObject(missle);
CreateExplosion(p, q, s, 7, 6.0);
CreateExplosion(p, q, s, 7, 6.0);
return 1;
}
return 0;
}
public movemissle(playerid)
{
if(GetPVarInt(playerid, "mc") == 1)
{
new Float:g, Float:h, Float:i, Float:j;
new keys, ud, lr;
GetPlayerKeys(playerid, keys, ud, lr);
GetObjectPos(missle, g, h, i);
if(ud < 0)
{
MapAndreas_FindZ_For2DCoord(g, h, j);
SetObjectPos(missle, g+1, h, j+50);
SetPlayerCameraPos(playerid, g+1, h, j+60);
SetPlayerCameraLookAt(playerid, g+1, h, j);
}
if(ud > 0)
{
MapAndreas_FindZ_For2DCoord(g, h, j);
SetObjectPos(missle, g-1, h, j+50);
SetPlayerCameraPos(playerid, g-1, h, j+60);
SetPlayerCameraLookAt(playerid, g-1, h, j);
}
if(lr < 0)
{
MapAndreas_FindZ_For2DCoord(g, h, j);
SetObjectPos(missle, g, h+1, j+50);
SetPlayerCameraPos(playerid, g, h+1, j+60);
SetPlayerCameraLookAt(playerid, g, h+1, j);
}
if(lr > 0)
{
MapAndreas_FindZ_For2DCoord(g, h, j);
SetObjectPos(missle, g, h-1, j+50);
SetPlayerCameraPos(playerid, g, h-1, j+60);
SetPlayerCameraLookAt(playerid, g, h-1, j);
}
}
}