GPS System
#7

pawn Код:
#define DIALOG_GPS      4

new GPS;
new gpsstr[256];
new bool:GPS_Activated[MAX_PLAYERS];

enum gInfo
{
    gName[128],
    Float:gX,
    Float:gY,
    Float:gZ
}
new GPSInfo[MAX_GPS][gInfo];

stock AddGPS(name[], Float:x, Float:y, Float:z)
{
    strcat(GPSInfo[GPS][gName],name,128);
    GPSInfo[GPS][gX] = x;
    GPSInfo[GPS][gY] = y;
    GPSInfo[GPS][gZ] = z;
    GPS++;
}

public ResetVariables(playerid)
{
    GPS_Activated[playerid] = false;
    return 1;
}
//

public OnPlayerEnterCheckpoint(playerid)
{
    if(GPS_Activated[playerid])
    {
        SendClientMessage(playerid, COLOR_GREEN, "[GPS]:You have arrived at your destenation.");
        DisablePlayerCheckpoint(playerid);
        GPS_Activated[playerid] = false;
    }
    return 1;
}

public OnFilterScriptInit()
{
    print("GPS System successfuly loaded!");

    AddGPS("Las Venturas Police Departement", 2289.99,2418.84,10.39);
    AddGPS("Las Venturas Fuckyea.", 2289.99,2418.84,10.39);

    for(new i; i < GPS; i++)
        format(gpsstr,256,"%s%s\n",gpsstr,GPSInfo[i][gName]);

    return 1;
}

//Public OnDialogResponse.
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new pname[MAX_PLAYER_NAME], string[63 + MAX_PLAYER_NAME];
    switch(dialogid)
    {
        case DIALOG_GPS:
        {
            if(!response) return 1;
            SetPlayerCheckpoint(playerid, GPSInfo[listitem][gX], GPSInfo[listitem][gY], GPSInfo[listitem][gZ],5.0);
            GPS_Activated[playerid] = true;
        }
    }
    return 1;
}

//============================================================================//
dcmd_gps(playerid,params[])
{
    #pragma unused params
    if(GPS_Activated[playerid]) SendClientMessage(playerid, COLOR_RED, "[GPS] Your GPS is already on.");
    else if(!IsPlayerInAnyVehicle(playerid))
    {
        SendClientMessage(playerid, COLOR_RED, "[GPS] You must be in a vehicle to use this command.");
        GPS_Activated[playerid] = false;
    }
    else
    {
        SendClientMessage(playerid, COLOR_GREEN,"[GPS] You have turned on your GPS.");
        ShowPlayerDialog(playerid, DIALOG_GPS, DIALOG_STYLE_LIST, "GPS:", gpsstr, "Choose", "Cancel");
        GPS_Activated[playerid] = true;
    }
    return 1;
}
//============================================================================//
dcmd_gpsoff(playerid,params[])
{
    #pragma unused params
    if(!GPS_Activated[playerid]) SendClientMessage(playerid, COLOR_RED, "[GPS] Your GPS isn't turned on.");
    else{
        DisablePlayerCheckpoint(playerid);
        SendClientMessage(playerid, COLOR_GREEN, "[GPS] You have turned off your GPS.");
        GPS_Activated[playerid] = false;
    }
    return 1;
}
Reply


Messages In This Thread
GPS System - by _Khaled_ - 31.08.2012, 19:08
Re: GPS System - by _Khaled_ - 31.08.2012, 22:20
Re: GPS System - by Kirollos - 31.08.2012, 22:29
Re: GPS System - by _Khaled_ - 31.08.2012, 23:35
Re: GPS System - by ThePhenix - 31.08.2012, 23:41
Re: GPS System - by _Khaled_ - 31.08.2012, 23:45
Re: GPS System - by Jefff - 31.08.2012, 23:53
Re: GPS System - by FalconX - 31.08.2012, 23:53
Re: GPS System - by _Khaled_ - 01.09.2012, 00:17
Re: GPS System - by _Khaled_ - 01.09.2012, 00:21

Forum Jump:


Users browsing this thread: 1 Guest(s)