All pastes #635205 Raw Edit

Jin

public text v1 · immutable
#635205 ·published 2007-07-26 22:21 UTC
rendered paste body
// ----------------------------------------------------------------------------------------------------
// Includes

#include <a_samp>
#include <core>
#include <float>
#include <dini>
#include <dudb>
#include <dutils>

// ----------------------------------------------------------------------------------------------------
// Defines

// Colors
#define COLOR_WHITE         0xFFFFFFAA
#define COLOR_ORANGE        0xFF9900AA
#define COLOR_IVORY         0xFFFF82FF
#define COLOR_BLUE          0x0000FFFF
#define COLOR_PURPLE        0x800080FF
#define COLOR_RED           0xFF0000FF
#define COLOR_LIGHTGREEN    0x00FF7FFF
#define COLOR_VIOLET        0xEE82EEFF
#define COLOR_YELLOW        0xFFFF00FF
#define COLOR_SILVER        0xC0C0C0FF
#define COLOR_LIGHTBLUE     0x87CEFAFF
#define COLOR_PINK          0xFFB6C1FF
#define COLOR_INDIGO        0x4B00B0FF
#define COLOR_GOLD          0xFFD700FF
#define COLOR_FIREBRICK     0xB22222FF
#define COLOR_GREEN         0x008000FF
#define COLOR_LIGHTYELLOW   0xFAFA02FF
#define COLOR_GREY          0x778899FF
#define COLOR_MAGENTA       0xFF00FFFF
#define COLOR_BRIGHTGREEN   0x7CFC00FF
#define COLOR_DARKBLUE      0x000080AF
#define COLOR_VIOLETRED     0xDB7093FF
#define COLOR_BROWN         0x8B4513FF
#define COLOR_GREENYELLOW   0xADFF2FFF
#define COLOR_THISTLE       0xD8BFD8FF
#define COLOR_TURQUISE      0x48D1CCFF
#define COLOR_MAROON        0x800000FF
#define COLOR_STEELBLUE     0xB0C4DEFF

// Player Colors
#define COLOR_PLAYER_LIGHTBLUE         0x9292FFDD
#define COLOR_PLAYER_BLUE              0x0000FFDD
#define COLOR_PLAYER_DARKBLUE          0x000096DD
#define COLOR_PLAYER_SPECIALBLUE       0x4169FFDD
#define COLOR_PLAYER_LIGHTRED          0xFFB0B0DD
#define COLOR_PLAYER_RED               0xFF0000DD
#define COLOR_PLAYER_DARKRED           0xA10000DD
#define COLOR_PLAYER_SPECIALRED        0xB22222DD
#define COLOR_PLAYER_LIGHTGREEN        0x92FF92DD
#define COLOR_PLAYER_GREEN             0x00FF00DD
#define COLOR_PLAYER_DARKGREEN         0x009600DD
#define COLOR_PLAYER_SPECIALGREEN      0x7ACA7ADD
#define COLOR_PLAYER_LIGHTYELLOW       0xFFFF5EDD
#define COLOR_PLAYER_YELLOW            0xFFFF00DD
#define COLOR_PLAYER_DARKYELLOW        0xD3D300DD
#define COLOR_PLAYER_SPECIALYELLOW     0xCFAE00DD
#define COLOR_PLAYER_LIGHTPURPLE       0xFF92FFDD
#define COLOR_PLAYER_PURPLE            0xFF00FFDD
#define COLOR_PLAYER_DARKPURPLE        0x800080DD
#define COLOR_PLAYER_SPECIALPURPLE     0xDA70D6DD
#define COLOR_PLAYER_LIGHTBROWN        0xBA9072DD
#define COLOR_PLAYER_BROWN             0x8B4513DD
#define COLOR_PLAYER_DARKBROWN         0x6D360EDD
#define COLOR_PLAYER_LIGHTGREY         0xC7C7C7DD
#define COLOR_PLAYER_GREY              0x8B8B8BDD
#define COLOR_PLAYER_DARKGREY          0x656565DD
#define COLOR_PLAYER_WHITE             0xFFFFFFDD
#define COLOR_PLAYER_BLACK             0x000000DD
#define COLOR_PLAYER_AQUAMARINE        0x7FFFD4DD
#define COLOR_PLAYER_CYAN              0x00FFFFDD

// Spawn Locations
#define SL_SHIP1                       0
#define SL_SHIP2                       1
#define SL_SHIP3                       2
#define SL_SHIP4                       3
#define SL_SHIP5                       4
#define SL_SHIP6                       5
#define SL_SHIP7                       6
#define SL_SHIP8                       7


// Macros
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

// Files
#define FILE_SETTINGS       "settings.ini"

// Misc
#define INI_PATH            "xadmin\"
#define MAX_CLASSES         300

// ----------------------------------------------------------------------------------------------------
// Global Variables

// Players - Basic
new pLogged[MAX_PLAYERS];
new pMoney[MAX_PLAYERS];
new pBankMoney[MAX_PLAYERS];
new pName[MAX_PLAYERS];
new pID[MAX_PLAYERS];
new pSpawnLocation[MAX_PLAYERS];
new pState[MAX_PLAYERS];

// Players - Stats
new pLevel[MAX_PLAYERS];
new pRespect[MAX_PLAYERS];
new pSpawnHealth[MAX_PLAYERS];
new pSpawnArmor[MAX_PLAYERS];
new pStatPoints[MAX_PLAYERS];

// Players - Guns & Ammo
new pGun1[MAX_PLAYERS];
new pGun2[MAX_PLAYERS];
new pGun3[MAX_PLAYERS];
new pGun4[MAX_PLAYERS];
new pGun5[MAX_PLAYERS];
new pAmmo1[MAX_PLAYERS];
new pAmmo2[MAX_PLAYERS];
new pAmmo3[MAX_PLAYERS];
new pAmmo4[MAX_PLAYERS];
new pAmmo5[MAX_PLAYERS];

// Money Defaults
new startingMoney = 5000;
new welfare = 500;
new welfareLimit = 2000000;
new holdPay = 100;

// Locations - Spawn
new float:locShipSpawns[8][3] = {
    { 2004.2555, 1521.8010, 17.0682 },
    { 1997.4397, 1521.4657, 17.0625 },
    { 1996.6748, 1533.9108, 14.6172 },
    { 2003.9340, 1533.6292, 14.6223 },
    { 2003.8167, 1555.2704, 14.4799 },
    { 1997.7933, 1555.3453, 14.4828 },
    { 2000.6272, 1566.4745, 15.3672 },
    { 1998.1041, 1544.3392, 14.4938 }
};

// ----------------------------------------------------------------------------------------------------
// Forward Functions

// / - Account
forward dcmd_Register();
forward dcmd_Login();

// / - Bank
forward dcmd_Bank(amount);
forward dcmd_BankAll();
forward dcmd_Withdraw(amount);
forward dcmd_Deposit(amount);

// Player
forward P_GetInfo(playerid);
forward P_SetupPlayerForSpawn(playerid);

// ----------------------------------------------------------------------------------------------------
// Functions

// Main. Don't you know what this is for? :P
main()
{
        print("\n----------------------------------------------------------------------");
        print("   XTRO Freeroam <-> Created by Jin | Version 0.0.1 (Serious Testing)");
        print("   This Mod is based on Ideas and Code from Nitro's Freeroam v3.4.0)");
        print("----------------------------------------------------------------------\n");
}

public OnGameModeInit()
{
	SetGameModeText("Xtro FreeRoam");
	ShowNameTags(1);
	ShowPlayerMarkers(1);
	SetWorldTime(0);
	UsePlayerPedAnims();
	
	for (new i = 1; i < MAX_CLASSES; i++)
	{
		AddPlayerClass(i, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0);
	}
}

public OnPlayerConnect(playerid)
{
	new str[256];
	
	for (new i = 0; i < MAX_PLAYERS; i++)
	{
		pLogged[i] = 0;
		pMoney[i] = 0;
		pBankMoney[i] = 0;
		pName[i] = 0;
		pID[i] = 0;
		pSpawnLocation[i] = 0;
		pState[i] = 0;
		pLevel[i] = 0;
		pRespect[i] = 0;
		pSpawnHealth[i] = 0;
		pSpawnArmor[i] = 0;
		pStatPoints[i] = 0;
		pGun1[i] = 0;
		pGun2[i] = 0;
		pGun3[i] = 0;
		pGun4[i] = 0;
		pGun5[i] = 0;
		pAmmo1[i] = 0;
		pAmmo2[i] = 0;
		pAmmo3[i] = 0;
		pAmmo4[i] = 0;
		pAmmo5[i] = 0;
	}
	
	P_GetInfo(playerid);

	GetPlayerName(playerid, pName[playerid], 30);
	format(str, 256, "%s has joined the server", pName[playerid]);
	SendClientMessageToAll(COLOR_GREEN, str);
	
	P_SetupPlayerForSpawn(playerid);
}

public OnPlayerDisconnect(playerid, reason)
{
	new str[256];
	
	GetPlayerName(playerid, pName[playerid], 30);
	switch (reason)
	{
		case 0: format(str, 256, "%s has left the server (Ping Timeout)", pName[playerid]);
		case 1: format(str, 256, "%s has left the server (Leaving)", pName[playerid]);
		case 2: format(str, 256, "%s has left the server (Kicked)", pName[playerid]);
	}
	
	SendClientMessageToAll(COLOR_RED, str);
}

public P_GetInfo(playerid)
{
	if (IsPlayerConnected(playerid))
	{
		if (dini_Exists(pName[playerid]))
		{
			print("Loading INI file for %s", pName[playerid]);
				
			pMoney[playerid] = dini_Int(pName[playerid], "Money");
			pLevel[playerid] = dini_Int(pName[playerid], "Level");
			pRespect[playerid] = dini_Int(pName[playerid], "Respect");
			pBankMoney[playerid] = dini_Int(pName[playerid], "Bank");
			pSpawnLocation[playerid] = dini_Int(pName[playerid], "Spawn");
			pSpawnHealth[playerid] = dini_Int(pName[playerid], "SpawnHealth");
			pSpawnArmor[playerid] = dini_Int(pName[playerid], "SpawnArmor");
			pStatPoints[playerid] = dini_Int(pName[playerid], "StatPoints");
			pGun1[playerid] = dini_Int(pName[playerid], "Gun1");
			pGun2[playerid] = dini_Int(pName[playerid], "Gun2");
			pGun3[playerid] = dini_Int(pName[playerid], "Gun3");
			pGun4[playerid] = dini_Int(pName[playerid], "Gun4");
			pGun5[playerid] = dini_Int(pName[playerid], "Gun5");
			pAmmo1[playerid] = dini_Int(pName[playerid], "Ammo1");
			pAmmo2[playerid] = dini_Int(pName[playerid], "Ammo2");
			pAmmo3[playerid] = dini_Int(pName[playerid], "Ammo3");
			pAmmo4[playerid] = dini_Int(pName[playerid], "Ammo4");
			pAmmo5[playerid] = dini_Int(pName[playerid], "Ammo5");
		}
		else
		{
			print("Creating INI file for %s", pName[playerid]);
			dini_Create(pName[playerid]);
			
			dini_IntSet(pName[playerid], "Money", 5000);
			dini_IntSet(pName[playerid], "Level", 1);
			dini_IntSet(pName[playerid], "Respect", 0);
			dini_IntSet(pName[playerid], "Bank", 0);
			dini_IntSet(pName[playerid], "Spawn", 0);
			dini_IntSet(pName[playerid], "SpawnHealth", 50);
			dini_IntSet(pName[playerid], "SpawnArmor", 0);
			dini_IntSet(pName[playerid], "StatPoints", 0);
			dini_IntSet(pName[playerid], "Gun1", 0);
			dini_IntSet(pName[playerid], "Gun2", 0);
			dini_IntSet(pName[playerid], "Gun3", 0);
			dini_IntSet(pName[playerid], "Gun4", 0);
			dini_IntSet(pName[playerid], "Gun5", 0);
			dini_IntSet(pName[playerid], "Ammo1", 0);
			dini_IntSet(pName[playerid], "Ammo2", 0);
			dini_IntSet(pName[playerid], "Ammo3", 0);
			dini_IntSet(pName[playerid], "Ammo4", 0);
			dini_IntSet(pName[playerid], "Ammo5", 0);
		}
	}
}

public P_SetupPlayerForSpawn(playerid)
{
	new spawnpt = dini_Int(pName[playerid], "Spawn");
	switch (spawnpt)
	{
		case SL_SHIP1: SetPlayerPos(playerid, locShipSpawns[0][0], locShipSpawns[0][1], locShipSpawns[0][2]);
		case SL_SHIP2: SetPlayerPos(playerid, locShipSpawns[1][0], locShipSpawns[1][1], locShipSpawns[1][2]);
		case SL_SHIP3: SetPlayerPos(playerid, locShipSpawns[2][0], locShipSpawns[2][1], locShipSpawns[2][2]);
		case SL_SHIP4: SetPlayerPos(playerid, locShipSpawns[3][0], locShipSpawns[3][1], locShipSpawns[3][2]);
		case SL_SHIP5: SetPlayerPos(playerid, locShipSpawns[4][0], locShipSpawns[4][1], locShipSpawns[4][2]);
		case SL_SHIP6: SetPlayerPos(playerid, locShipSpawns[5][0], locShipSpawns[5][1], locShipSpawns[5][2]);
		case SL_SHIP7: SetPlayerPos(playerid, locShipSpawns[6][0], locShipSpawns[6][1], locShipSpawns[6][2]);
		case SL_SHIP8: SetPlayerPos(playerid, locShipSpawns[7][0], locShipSpawns[7][1], locShipSpawns[7][2]);
	}
}