Timer Function not allowing compilation.
#1

So, I've had an idea for a while. I just began scripting it. I'm not going to go into full detail what the final script is going to do, but as of right now, that part is undeveloped. I'm trying to create a timer that will update a textdraw with the player's current coordinates while they are within a certain distance of a certain point for debug and coordinate gathering purposes. (I cba to use /save all the time)

Here's my current code.
pawn Код:
#include <a_samp>

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Area 69 Radar by ThatOneDude");
    print(" Version: 0.2c (see Changelog below)");
    print("--------------------------------------");
    print(" Changelog");
    print(" -------------");
    print(" 0.1a Player Radar Area Detection.");
    print(" 0.2a Radar Area increased to full range.");
    print(" 0.2a Vehicles added for testing.");
    print(" 0.2b Vehicle detection for radar.");
    print(" 0.2c Debug coords added for player.");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/radar", cmdtext, true, 10) == 0)
    {
        new vehicle;
        if(IsPlayerInAnyVehicle(playerid))
        {
            vehicle = GetPlayerVehicleID(playerid);
            SetVehiclePos(vehicle,157.7753,1898.3188,19.5899);
        }
        else
        {
            SetPlayerPos(playerid,157.7753,1898.3188,18.5899);
        }
        return 1;
    }
    if (strcmp("/limit", cmdtext, true, 10) == 0)
    {
        new vehicle;
        if(IsPlayerInAnyVehicle(playerid))
        {
            vehicle = GetPlayerVehicleID(playerid);
            SetVehiclePos(vehicle,258.4408,1252.5393,16.7816);
        }
        else
        {
            SetPlayerPos(playerid,258.4408,1252.5393,15.7816);
        }
        return 1;
    }
    if (strcmp("/cars", cmdtext, true, 10) == 0)
    {
        DestroyVehicle(0);
        DestroyVehicle(1);
        DestroyVehicle(2);
        AddStaticVehicle(568, 175.3102,1913.9052,18.1204, 180.0000, 0, 0);
        AddStaticVehicle(470, 164.4936,1916.3516,18.4934, 180.0000, 0, 0);
        AddStaticVehicle(520, 150.1823,1921.6815,18.9860, 180.0000, 0, 0);
        return 1;
    }
    return 0;
}

new Text:iDrawCoords[MAX_PLAYERS];

forward UpdateLoc(playerid);

public OnPlayerConnect(playerid)
{
    iDrawCoords[playerid] = TextDrawCreate(200,400,"Out of range.");
    TextDrawSetOutline(iDrawCoords[playerid], 1);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer(playerid,iDrawCoords[playerid]);
    return 1;
}

public OnPlayerUpdate(playerid)
{
    new iRadRg = IsPlayerInRangeOfPoint(playerid,653.5783,157.7753,1898.3188,18.5899);
    if(iRadRg != GetPVarInt(playerid, "iRadarRange"))
    {
        if(iRadRg > GetPVarInt(playerid, "iRadarRange"))
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                SendClientMessage(playerid, 0xFF000000, "Your vehicle is within range of Area 69's radar!");
                SetTimerEx("UpdateLoc",250,1,"i",playerid);
            }
            else
            {
                SendClientMessage(playerid, 0xFF000000, "You are within range of Area 69's radar!");
                SetTimerEx("UpdateLoc",250,1,"i",playerid);
            }
        }
        else
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                SendClientMessage(playerid, 0x00FF0000, "Your vehicle has left range of Area 69's radar!");
                SetTimerEx("UpdateLoc",250,0,"i",playerid);
                TextDrawSetString(iDrawCoords[playerid],"Out of range.");
            }
            else
            {
                SendClientMessage(playerid, 0x00FF0000, "You have left range of Area 69's radar!");
                SetTimerEx("UpdateLoc",250,0,"i",playerid);
                TextDrawSetString(iDrawCoords[playerid],"Out of range.");
            }
        }
        SetPVarInt(playerid, "iRadarRange", iRadRg);
    }
    return 1;
}

public UpdateLoc(playerid);
{
    new Float:PosX, Float:PosY, Float:PosZ;
    GetPlayerPos(playerid,PosX,PosY,PosZ);
    TextDrawSetString(iDrawCoords[playerid],"%f,%f,%f",PosX,PosY,PosZ);
    return 1;
}

public OnPlayerDeath(playerid)
{
    TextDrawHideForPlayer(playerid,iDrawCoords[playerid]);
    return 1;
}

public OnPlayerDisconnect(playerid)
{
    TextDrawDestroy(iDrawCoords[playerid]);
    DeletePVar(playerid, "iRadarRange");
    return 1;
}
Here's the compiler errors.
Код:
C:\Users\Nicholas Duff\Desktop\samp03bsvr_R2_win32\filterscripts\area69radar.pwn(124) : error 055: start of function body without function header
C:\Users\Nicholas Duff\Desktop\samp03bsvr_R2_win32\filterscripts\area69radar.pwn(126) : error 021: symbol already defined: "GetPlayerPos"
C:\Users\Nicholas Duff\Desktop\samp03bsvr_R2_win32\filterscripts\area69radar.pwn(128) : error 010: invalid function or declaration
C:\Users\Nicholas Duff\Desktop\samp03bsvr_R2_win32\filterscripts\area69radar.pwn(143) : warning 203: symbol is never used: "PosX"
C:\Users\Nicholas Duff\Desktop\samp03bsvr_R2_win32\filterscripts\area69radar.pwn(143) : warning 203: symbol is never used: "PosY"
C:\Users\Nicholas Duff\Desktop\samp03bsvr_R2_win32\filterscripts\area69radar.pwn(143) : warning 203: symbol is never used: "PosZ"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Thanks for looking and for any help you can give.
Reply
#2

pawn Код:
public UpdateLoc(playerid);
Remove the ';'

pawn Код:
public UpdateLoc(playerid)
Reply
#3

Thanks...figured it would be a stupid mistake. :P

Sometimes just need an outsider's perspective to see things correctly.

After removing that, I get the following:
Код:
C:\Users\Nicholas Duff\Desktop\samp03bsvr_R2_win32\filterscripts\area69radar.pwn(127) : warning 202: number of arguments does not match definition
C:\Users\Nicholas Duff\Desktop\samp03bsvr_R2_win32\filterscripts\area69radar.pwn(127) : warning 202: number of arguments does not match definition
C:\Users\Nicholas Duff\Desktop\samp03bsvr_R2_win32\filterscripts\area69radar.pwn(127) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Warnings.
Reply
#4

pawn Код:
public UpdateLoc(playerid)
{
    new Float:PosX, Float:PosY, Float:PosZ;
    GetPlayerPos(playerid,PosX,PosY,PosZ);
    new string[64];
    format(string, sizeof(string), "%f,%f,%f",PosX,PosY,PosZ);
    TextDrawSetString(iDrawCoords[playerid],string);
    return 1;
}
Reply
#5

Thanks again, solved the problem. I also got rid of the ugly timers that are set not to repeat when the player leaves the radar range. I replaced them will KillTimer, figuring it would work better. Will test the changes and if anything else arises, I will be sure to let you know.

Regards,
ThatOneDude
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)