predator problem
#1

hey everyone,

I've made a predator missle system but it has a major bug: only id 0 can use it.

i hope you can help.

pawn Код:
//------------------------------
//Predator missle V1.0.01 by sansko
//------------------------------
#include <a_samp>
#include <mapandreas>
//------------------------------
new missle;
new control;
new timermovemissle;

#define speed 15

forward movemissle(playerid);

public OnFilterScriptInit()
{
    print("Air to ground missle is online");
    MapAndreas_Init(MAP_ANDREAS_MODE_FULL);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/predator", cmdtext, true, 10) == 0)
    {
        if(control == 0)
        {
            new Float:a, Float:b, Float:c ;
            new Float:f ;
            control = 1;
            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);
            timermovemissle = SetTimer("movemissle", 100, true);
            TogglePlayerControllable(playerid, 0);
            return 1;
        }
        return SendClientMessage(playerid, 0x00ffAA, "the missle is already in control.");
    }
    if (strcmp("/camreset", cmdtext, true, 10) == 0)
    {
        SetCameraBehindPlayer(playerid);
        SetPVarInt(playerid, "mc", 0);
        TogglePlayerControllable(playerid, 1);
        control = 0;
        KillTimer(timermovemissle);
        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(timermovemissle);
        control = 0;
        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);
        }
    }
}
i hope that you can help me.
if it works i will credit you for fixing this.

Thanks in Advance,

Sansko
Reply
#2

Please help, i really need this.
Reply
#3

Since SetTimer can NOT pass parameters (playerid, vehicleid and user-defined) you might want to use SetTimerEx
Reply
#4

thanks i will try to do that
"to myself (YouNoob)"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)