SA-MP Crashing with my code
#1

OK, My SAMP is crashing because of something in my code:
Код:
/*///////////////////
MWFFA - New Script

Work Started on June 18, 2012

*//////////////////

#include <a_samp>
#include <streamer>
#include <irc>
#include <YSI/y_ini>

//Path
#define PATH "MWFFA/Accounts/%s.ini"

//Teams
#define TEAM_DELTA 1
#define TEAM_SPETSNAZ 2
#define TEAM_GIGN 3
#define TEAM_IA 4
#define TEAM_JSDF 5

//Dialogs
#define DIALOG_CTEAM   8343
#define DIALOG_SCLASS   10211
#define DIALOG_SSTEAM   3893
#define DIALOG_LOGIN   28385
#define DIALOG_LOGIN_2   16349
#define DIALOG_REGISTER   2656
#define DIALOG_REGISTER_2   22829


//IRC Stuff
#define IRC_SERVER "irc.mibbit.net"
#define IRC_PORT (6667)
#define IRC_CHANNEL "#MWFFA"

#define BOT_1_NICKNAME "Overlord"
#define BOT_1_REALNAME "SA-MP Bot"
#define BOT_1_USERNAME "Overlord_1"

#define MAX_BOTS (1)

new gBotID[MAX_BOTS], gGroupID;

//Takeover Timers
new TT[MAX_PLAYERS];
new T2[MAX_PLAYERS];
new T3[MAX_PLAYERS];

//UDB Hash
stock udb_hash(buf[])
{
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}

//Defines
#define MAX_ZONES 50

//Colors
#define COLOR_RED 0xFF0000FF
#define COLOR_YELLOW 0xFFFF00FF
#define COLOR_PINK 0xFF00FFFF
#define COLOR_GREEN 0x00FF00FF
#define COLOR_AQUA 0x00FFFFFF
#define COLOR_BLACK 0x000000FF
#define COLOR_BLUE 0x0000FFFF

//Skins
#define SKIN_TORENO 295
#define SKIN_WUZIMU 294
#define SKIN_USA 287
#define SKIN_RUSSIA 179
#define SKIN_GIGN 285
#define SKIN_IA 254
#define SKIN_JSDF 57

//Zones
new Z_KACC;
new Z_School;
new Z_Pier;
new Z_DOCK;


//Forwards
forward ASKOff(playerid);

//Enums
enum kInfo
{
    HasStreak,
    HasPackage,
    HasStrike,
    HasGunner,
    HasTank,
    HasJug,
	HasNuke,
    Streak
}
new StreakInfo[MAX_PLAYERS][kInfo];

enum pInfo
{
    Password,
    Cash,
    Score,
    Admin,
    Points,
    Xp,
    Protected,
    CapturingZone,
    Connects,
    Disconnects,
	LoginAttempts
}
new PlayerInfo[MAX_PLAYERS][pInfo];

//Class Variables
new IsSoldier[MAX_PLAYERS];
new IsSniper[MAX_PLAYERS];
new IsMedic[MAX_PLAYERS];
new IsEngineer[MAX_PLAYERS];
new IsPilot[MAX_PLAYERS];
new IsFlamethrower[MAX_PLAYERS];
new IsSpy[MAX_PLAYERS];
new IsScout[MAX_PLAYERS];
new IsPlaneDriver[MAX_PLAYERS];
new IsHeliDriver[MAX_PLAYERS];
new IsGeneral[MAX_PLAYERS];
new IsVIP[MAX_PLAYERS];
new IsAdmin[MAX_PLAYERS];
new IsOwner[MAX_PLAYERS];

//Capture var
new EnteredArea[MAX_PLAYERS];
new CapturedBy; // 0 ( none ) 1 ( Delta ) 2 ( Russia ) 3 - GIGN | 4 - Italian Army | 5 - JSDF
new EnteredArea2[MAX_PLAYERS];
new CapturedBy2; //Same as above
new EnteredArea3[MAX_PLAYERS];
new CapturedBy3; //Same

//UserPath
stock UserPath(playerid)
{
	new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string, sizeof(string),PATH,playername);
    return string;
}

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

main()
{
    print("\n----------------------------------");
    print("------- MWFFA Script Loaded --------");
    print("----------------------------------\n");
}


public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("MWFFA - World War lll");
    
    //Zones
    Z_KACC = GangZoneCreate(2438.989, 2560.181, 2782.616, 2885.098);
    Z_School = GangZoneCreate(-2197.686, -281.7203, -2008.414, -68.69224);
    Z_Pier = GangZoneCreate(371.8314, -2108.218, 459.2966, -1654.228);
    Z_DOCK = GangZoneCreate(2228.381375, -2228.381375, 2866.962306, -2813.747228);

    //IRC
    gBotID[0] = IRC_Connect(IRC_SERVER, IRC_PORT, BOT_1_NICKNAME, BOT_1_REALNAME, BOT_1_USERNAME);
    IRC_SetIntData(gBotID[0], E_IRC_CONNECT_DELAY, 20);
    gGroupID = IRC_CreateGroup();

    SetTimer("AreaCheck", 1000, true);
    
    CapturedBy = 2;
    CapturedBy2 = 5;
    CapturedBy3 = 4;
    
    //Random Messages
	SetTimer("RM",90000,true);
    return 1;
}

public OnGameModeExit()
{
    print("\n------------------------------------");
    print("------- MWFFA Script unloaded --------");
    print("--------------------------------------\n");

    IRC_Quit(gBotID[0], "Overlord (SA-MP Bot) exiting.");
    IRC_DestroyGroup(gGroupID);
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);

    GangZoneShowForPlayer(playerid, Z_KACC, 0xFF000096);
    GangZoneShowForPlayer(playerid, Z_School, 0xFF800096);
    GangZoneShowForPlayer(playerid, Z_Pier, 0xFFFF0096);
    GangZoneShowForPlayer(playerid, Z_DOCK, 0x00FFFFFF);

    //Select Team
    ShowPlayerDialog(playerid, DIALOG_CTEAM, DIALOG_STYLE_LIST, "Choose Team", "Delta Force (United States)\nSpetsnaz (Russia)\nGIGN (France)\nItalian Army (Italy)\nJapan Self Defense Forces (Japan)", "Select", "");
    return 1;
}

public OnPlayerConnect(playerid)
{
    new string[100];
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(string, sizeof(string),"*** %s(%d) has joined the server.");
    IRC_GroupSay(gGroupID, IRC_CHANNEL, string);
    PlayerInfo[playerid][Connects]++;
    
    if(fexist(UserPath(playerid)))
    {
		ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "{CFCC92}MWFFA\n\n\t\tWelcome to MWFFA!\n\n\t\tPlease enter your password to start the game!", "Join the Action", "Get Kicked");
	}
	else
	{
	    ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register", "\t\t\n{00FF00}MWFFA\n\n\t{0000FF}Welcome on the server!\n\t{0000FF}Please register to start the game!", "Join the Action", "Get Kicked");
	}
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new reasonMsg[20];
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));

    switch(reason)
    {
        case 0: reasonMsg = "Timeout";
        case 1: reasonMsg = "Leaving";
        case 2: reasonMsg = "Kicked/Banned";
    }

    new string[70];
    format(string, sizeof(string),"*** %s(%d) has left the server (%s)", pName, playerid, reasonMsg);
    IRC_GroupSay(gGroupID, IRC_CHANNEL, string);
    format(string, sizeof(string),"-| %s(%d) has left the server! (%s) |-", pName, playerid, reasonMsg);
    SendClientMessageToAll(COLOR_PINK, string);
    PlayerInfo[playerid][Disconnects]++;
    return 1;
}

public OnPlayerSpawn(playerid)
{
    SendClientMessage(playerid, COLOR_YELLOW, "You are anti-spawn kill protected for 10 seconds");
    PlayerInfo[playerid][Protected] = 1;
    SetTimerEx("ASKOff", 10000, 0, "i", playerid);
    
	new team = GetPlayerTeam(playerid);
	if(team == TEAM_DELTA)
	{
	    SetPlayerSkin(playerid, SKIN_USA);
 	}

	if(team == TEAM_SPETSNAZ)
	{
	    SetPlayerSkin(playerid, SKIN_RUSSIA);
	}
	
	if(team == TEAM_GIGN)
	{
	    SetPlayerSkin(playerid, SKIN_GIGN);
	}
	
	if(team == TEAM_IA)
	{
	    SetPlayerSkin(playerid, SKIN_IA);
	}
	
	if(team == TEAM_JSDF)
	{
	    SetPlayerSkin(playerid, SKIN_JSDF);
	}
	
	//----------------//
	//Classes---------//
	//---------------//
	if(IsSoldier[playerid] == 1)
	{
	    GivePlayerWeapon(playerid, 22, 100);
	    GivePlayerWeapon(playerid, 32, 150);
	    GivePlayerWeapon(playerid, 31, 300);
	    GivePlayerWeapon(playerid, 41, 200);
 	}
 	
 	if(IsSniper[playerid] == 1)
 	{
 	    GivePlayerWeapon(playerid, 23, 50);
 	    GivePlayerWeapon(playerid, 28, 120);
 	    GivePlayerWeapon(playerid, 34, 400);
 	    GivePlayerWeapon(playerid, 17, 20);
	}
	
	if(IsMedic[playerid] == 1)
	{
	    GivePlayerWeapon(playerid, 24, 60);
	    GivePlayerWeapon(playerid, 32, 135);
	    GivePlayerWeapon(playerid, 31, 300);
	    GivePlayerWeapon(playerid, 41, 999999);
	}
	
	if(IsEngineer[playerid] == 1)
	{
	    GivePlayerWeapon(playerid, 22, 100);
	    GivePlayerWeapon(playerid, 26, 200);
	    GivePlayerWeapon(playerid, 31, 300);
	    GivePlayerWeapon(playerid, 16, 5);
	}
	
	if(IsPilot[playerid] == 1)
	{
	    GivePlayerWeapon(playerid, 22, 200);
	    GivePlayerWeapon(playerid, 29, 250);
	    GivePlayerWeapon(playerid, 31, 400);
	    GivePlayerWeapon(playerid, 46, 1);
	}
	
	if(IsFlamethrower[playerid] == 1)
	{
	    GivePlayerWeapon(playerid, 24, 300);
	    GivePlayerWeapon(playerid, 27, 200);
	    GivePlayerWeapon(playerid, 30, 400);
	    GivePlayerWeapon(playerid, 37, 200);
	    GivePlayerWeapon(playerid, 18, 15);
	}
	
	if(IsSpy[playerid] == 1)
	{
	    GivePlayerWeapon(playerid, 22, 100);
	    GivePlayerWeapon(playerid, 26, 200);
	    GivePlayerWeapon(playerid, 31, 300);
	    GivePlayerWeapon(playerid, 16, 5);
	}
	
	if(IsScout[playerid] == 1)
	{
	    GivePlayerWeapon(playerid, 4, 1);
     	GivePlayerWeapon(playerid, 23, 75);
      	GivePlayerWeapon(playerid, 29, 130);
       	GivePlayerWeapon(playerid, 31, 200);
	}
	
	if(IsPlaneDriver[playerid] == 1)
	{
	    GivePlayerWeapon(playerid, 26, 80);
     	GivePlayerWeapon(playerid, 29, 75);
      	GivePlayerWeapon(playerid, 33, 130);
       	GivePlayerWeapon(playerid, 31, 200);
       	GivePlayerWeapon(playerid, 46, 1);
	}
	
	if(IsHeliDriver[playerid] == 1)
	{
		GivePlayerWeapon(playerid, 26, 80);
     	GivePlayerWeapon(playerid, 29, 75);
      	GivePlayerWeapon(playerid, 33, 130);
       	GivePlayerWeapon(playerid, 31, 200);
       	GivePlayerWeapon(playerid, 46, 1);
	}
	
	if(IsGeneral[playerid] == 1)
	{
	    GivePlayerWeapon(playerid, 26, 500);
	    GivePlayerWeapon(playerid, 32, 650);
	    GivePlayerWeapon(playerid, 31, 800);
	    GivePlayerWeapon(playerid, 35, 3);
	    GivePlayerWeapon(playerid, 16, 10);
	}
	
	if(IsVIP[playerid] == 1)
	{
	    GivePlayerWeapon(playerid, 24, 1000);
	    GivePlayerWeapon(playerid, 28, 1300);
	    GivePlayerWeapon(playerid, 31, 1400);
	    GivePlayerWeapon(playerid, 36, 10);
		GivePlayerWeapon(playerid, 16, 10);
	}
	
	if(IsOwner[playerid] == 1)
	{
 		GivePlayerWeapon(playerid, 22, 999999);
   		GivePlayerWeapon(playerid, 32, 999999);
     	GivePlayerWeapon(playerid, 31, 999999);
      	GivePlayerWeapon(playerid, 38, 999999);
       	GivePlayerWeapon(playerid, 16, 999999);
	}
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    new string[100];
    new pName[MAX_PLAYER_NAME];
    new pNameTwo[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    GetPlayerName(killerid, pNameTwo, sizeof(pNameTwo));
    new reasonMsg[30];
    if(killerid != INVALID_PLAYER_ID)
    {
        switch (reason)
        {
            case 0: reasonMsg = "Unarmed";
            case 1: reasonMsg = "Brass Knuckles";
            case 2: reasonMsg = "Golf Club";
            case 3: reasonMsg = "Night Stick";
            case 4: reasonMsg = "Knife";
            case 5: reasonMsg = "Baseball Bat";
            case 6: reasonMsg = "Shovel";
            case 7: reasonMsg = "Pool Cue";
            case 8: reasonMsg = "Katana";
            case 9: reasonMsg = "Chainsaw";
            case 10: reasonMsg = "Dildo";
            case 11: reasonMsg = "Dildo";
            case 12: reasonMsg = "Vibrator";
            case 13: reasonMsg = "Vibrator";
            case 14: reasonMsg = "Flowers";
            case 15: reasonMsg = "Cane";
            case 22: reasonMsg = "Pistol";
            case 23: reasonMsg = "Silenced Pistol";
            case 24: reasonMsg = "Desert Eagle";
            case 25: reasonMsg = "Shotgun";
            case 26: reasonMsg = "Sawn-off Shotgun";
            case 27: reasonMsg = "Combat Shotgun";
            case 28: reasonMsg = "MAC-10";
            case 29: reasonMsg = "MP5";
            case 30: reasonMsg = "AK-47";
            case 31: reasonMsg = "M4";
            case 32: reasonMsg = "TEC-9";
            case 33: reasonMsg = "Country Rifle";
            case 34: reasonMsg = "Sniper Rifle";
            case 37: reasonMsg = "Fire";
            case 38: reasonMsg = "Minigun";
            case 41: reasonMsg = "Spray Can";
            case 42: reasonMsg = "Fire Extinguisher";
            case 49: reasonMsg = "Vehicle Collision";
            case 50: reasonMsg = "Vehicle Collision";
            case 51: reasonMsg = "Explosion";
            case 52: reasonMsg = "Bombing Run";
            case 53: reasonMsg = "Nuke";
            default: reasonMsg = "Unknown";
        }

        StreakInfo[killerid][Streak]++;
        StreakInfo[playerid][Streak] = 0;
        format(string, sizeof(string),"-| You have killed %s(%d) and have earned $250, and 5 XP |-", pName, playerid);
        SendClientMessage(killerid, COLOR_YELLOW, string);
        format(string, sizeof(string),"-| You have been killed by %s(%d) and have lost $100 |-", pNameTwo, killerid);
        SendClientMessage(playerid, COLOR_RED, string);
        PlayerInfo[playerid][Xp] += 5;
        GivePlayerScore(playerid, 5);
        GivePlayerMoney(killerid, 250);
        GivePlayerMoney(playerid, -100);
        format(string, sizeof(string),"*** %s(%d) has been killed by %s(%d). (%s)", pName, playerid, pNameTwo, killerid, reasonMsg);
        IRC_GroupSay(gGroupID, IRC_CHANNEL, string);

        if(GetPlayerTeam(killerid) == GetPlayerTeam(playerid))
        {
            SetPlayerArmour(killerid, 0.0);
            SetPlayerHealth(killerid, 0);
            GameTextForPlayer(killerid, "~r~Killed for Team-Kill & Charged $2500", 8000, 2);
            GameTextForPlayer(playerid, "The teammate who killed you has been killed for team kill!", 4500, 6);
            GivePlayerMoney(killerid, -2500);
        }
    }
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    new string[100];
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(string, sizeof(string),"*** %s(%d): %s", pName, playerid, text);
    IRC_GroupSay(gGroupID, IRC_CHANNEL, string);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(kill,4,cmdtext);
    dcmd(radio,5,cmdtext);
    dcmd(report,6,cmdtext);
    
    //Admin Commands
	dcmd(setlevel,8,cmdtext);
	
	//----------------------------------------------------------//
    
    //Commands to Admins
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	new string[100];
   	format(string, sizeof(string), "*** %s(%d) Command: %s", name,playerid,cmdtext);
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			if(PlayerInfo[i][Admin] > PlayerInfo[playerid][Admin] && PlayerInfo[i][Admin] > 1 && i != playerid)
			{
				SendClientMessage(i, 0x02000056, string);
			}
		}
	}
    return 1;
}

dcmd_kill(playerid, params[])
{
	#pragma unused params
    new string[100];
    new cRand = random(10000);
    SetPlayerHealth(playerid, 0);
    SetPlayerArmour(playerid, 0.0);
    format(string, sizeof(string), "You have been charged $%d for using /kill", cRand);
    SendClientMessage(playerid, COLOR_RED, string);
    GivePlayerMoney(playerid, -cRand);
    return 1;
}

dcmd_radio(playerid, params[])
{
	new Index;
    new tmp[256];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
	new string[100];
	tmp = strtok(params, Index);

    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
	        if(GetPlayerTeam(i) == GetPlayerTeam(playerid))
	        {
                format(string, sizeof(string), "[RADIO] %s(%d): %s", name, playerid, tmp);
				SendClientMessage(playerid, COLOR_GREEN, string);
			}
            else SendClientMessage(playerid, COLOR_RED, "ERROR: There is no one on your team right now to talk to.");
        }
    }
    return 1;
}

dcmd_report(playerid, params[])
{
	new Index;
	new tmp[256];
	tmp = strtok(params, Index);
	new tmp2[256];
	tmp2 = strtok(params, Index);
	new id;
	id = strval(tmp);
	
	new year,month,day;
	new hour,minute,sec;
	
	gettime(hour,minute,sec);
	getdate(year,month,day);
	
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	new name2[MAX_PLAYER_NAME];
	GetPlayerName(id, name2, sizeof(name2));
	new string[140];
	
	if(!strlen(params))
	{
	    SendClientMessage(playerid, COLOR_RED, "Usage: /report (ID) (Reason)");
	    SendClientMessage(playerid, COLOR_YELLOW, "Note: Only report someone with a valid reason");
		return 0;
	}
	
	if(!strlen(params[2]))
	{
	    SendClientMessage(playerid, COLOR_RED, "ERROR: No reason specified");
		return 0;
	}
	
	if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid player ID");
	if(id == playerid) return SendClientMessage(playerid, COLOR_RED, "ERROR: You cannot report yourself");
	
	format(string, sizeof(string),"[Date: %d/%d/%d] [Time: %d:%d:%d] Player %s reported %s | Reason: %s", year, month, day, hour, minute, sec, name, name2, tmp2);
	SaveIn("Reports",string);
	format(string, sizeof(string), "REPORT: %s(%d) reported %s(%d) - Reason: %s", name, playerid, name2, id, tmp2);
	MessageToAdmins(COLOR_YELLOW, string);
	format(string, sizeof(string), "-| You have successfully reported %s(%d) for reason: %s |-", name2, id, tmp2);
	SendClientMessage(playerid, COLOR_GREEN, string);
	return 1;
}

//--------------//
//Admin Commands//
//--------------//
dcmd_setlevel(playerid, params[])
{
	new id;
	new level;
	new pName1[MAX_PLAYER_NAME];
	new pName2[MAX_PLAYER_NAME];
	new string[150];
	new tmp [256];
	new tmp2[256];
	new Index;
	tmp  = strtok(params,Index);
	tmp2 = strtok(params,Index);

	if(!strlen(params))
 	{
		SendClientMessage(playerid, COLOR_RED, "Usage: /setlevel (ID) (Level [1-10])");
		return 0;
	}

	if(PlayerInfo[playerid][Admin] >= 9 || IsPlayerAdmin(playerid))
	{
	    id = strval(tmp);
	    level = strval(tmp2);
 		GetPlayerName(id, pName1, sizeof(pName1));
   		GetPlayerName(playerid, pName2, sizeof(pName2));

   		//Errors
   		if(level > 10 || level < 0) return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid Level");
		if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player not found");
		if(IsPlayerNPC(id)) return SendClientMessage(playerid, COLOR_RED, "ERROR: You can not use this command on NPCs");

		//If Successfull
	    PlayerInfo[id][Admin] = level;
	    new INI:File = INI_Open(UserPath(playerid));
	    INI_WriteInt(File,"Admin",level);
	    INI_Close(File);
		format(string, sizeof(string),"-| You have set %s(%d)'s admin level to %d |-", pName1, id, level);
		SendClientMessage(playerid, COLOR_AQUA, string);
		format(string, sizeof(string),"-| Adminstrator %s(%d) has set your adminstration level to %d |-", pName2, playerid, level);
		SendClientMessage(playerid, COLOR_AQUA, string);
	}
	else SendClientMessage(playerid, COLOR_RED, "ERROR: You need to be level 6 to use this command");
	return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(newstate == PLAYER_STATE_DRIVER)
	{
		new vehicleid = GetPlayerVehicleID(playerid);
  		if(GetVehicleModel(vehicleid) == 432 && IsEngineer[playerid] != 1 && IsVIP[playerid] != 1 && IsOwner[playerid] != 1)
		{
			SendClientMessage(playerid, COLOR_RED, "ERROR: You must be an engineer or owner to drive this.");
			RemovePlayerFromVehicle(playerid);
		}

		if(GetVehicleModel(vehicleid) == 425 && IsPilot[playerid] != 1 && IsVIP[playerid] != 1 && IsOwner[playerid] != 1)
		{
		    SendClientMessage(playerid, COLOR_RED, "ERROR: You must be a pilot or owner to pilot this.");
		    RemovePlayerFromVehicle(playerid);
		}
		
		if(GetVehicleModel(vehicleid) == 447 && IsPilot[playerid] != 1 && IsOwner[playerid] != 1)
		{
		    SendClientMessage(playerid, COLOR_RED, "ERROR: You must be a pilot or owner to pilot this.");
		    RemovePlayerFromVehicle(playerid);
		}
		
		if(GetVehicleModel(vehicleid) == 520 && IsPilot[playerid] != 1 && IsOwner[playerid] != 1)
		{
		    SendClientMessage(playerid, COLOR_RED, "ERROR: You must be a pilot or owner to pilot this.");
		    RemovePlayerFromVehicle(playerid);
		}
	}
    return 1;
}

public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    return 1;
}

public OnPlayerLeaveDynamicCP(playerid, checkpointid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    return 1;
}

public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid)
{
	new Float:health;
	GetPlayerHealth(playerid, health);
    if(PlayerInfo[damagedid][Protected] == 1)
    {
        GameTextForPlayer(playerid, "~r~This person is Anti-Spawn kill protected", 5000, 6);
        SetPlayerHealth(damagedid, 100);
        SetPlayerArmour(damagedid, 100.0);
    }
    
    if(GetPlayerTeam(damagedid) == GetPlayerTeam(playerid))
    {
        GameTextForPlayer(playerid, "~r~TEAM SHOOT | -5 HEALTH", 5000, 4);
        SetPlayerHealth(playerid, health-5);
	}
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    if(success)
    {
        printf("RCON login success by IP %s using password %s", ip, password);
    }
    else
    {
        printf("Failed RCON login by IP %s using password %s", ip, password);
    }
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_CTEAM)
    {
        ShowPlayerDialog(playerid, DIALOG_SCLASS, DIALOG_STYLE_LIST, "Select Class", "Soldier (0 XP)\nSniper (0 XP)\nMedic (30 XP)\nEngineer (75 XP)\nPilot (120 XP)\nFlamethrower (200 XP)\nSpy (310 XP)\nScout (350 XP)\nCargo plane Driver (500 XP)\nSupply Helicopter Driver (630 XP)\nGeneral (800 XP)\nVIP (1+ VIP Points)\nAdmin (Admin level 1+)\nOwner (Level 10)", "Go!", "");
        switch(listitem)
        {
            case 0:
            {
                SetPlayerTeam(playerid, TEAM_DELTA);
                SetPlayerColor(playerid, COLOR_BLUE);
                GameTextForPlayer(playerid, "~b~DELTA FORCE", 7500, 6);
                SetPlayerSkin(playerid, SKIN_USA);
            }
            case 1:
            {
                SetPlayerTeam(playerid, TEAM_SPETSNAZ);
                SetPlayerColor(playerid, COLOR_RED);
                GameTextForPlayer(playerid, "~r~SPETSNAZ", 7500, 6);
                SetPlayerSkin(playerid, SKIN_RUSSIA);
            }
            case 2:
            {
                SetPlayerTeam(playerid, TEAM_GIGN);
                SetPlayerColor(playerid, COLOR_GREEN);
                GameTextForPlayer(playerid, "~g~GIGN", 7500, 6);
                SetPlayerSkin(playerid, SKIN_GIGN);
            }
            case 3:
            {
                SetPlayerTeam(playerid, TEAM_IA);
                SetPlayerColor(playerid, COLOR_AQUA);
                GameTextForPlayer(playerid, "ITALIAN ARMY", 7500, 6);
                SetPlayerSkin(playerid, SKIN_IA);
            }
            case 4:
            {
                SetPlayerTeam(playerid, TEAM_JSDF);
                SetPlayerColor(playerid, 0xFF800096);
                GameTextForPlayer(playerid, "Japan Self Defense Forces", 7500, 6);
                SetPlayerSkin(playerid, SKIN_JSDF);
            }
        }
    }

    if(dialogid == DIALOG_SCLASS)
    {
        switch(listitem)
        {
            case 0:
            {
                IsSoldier[playerid] = 1;
                GameTextForPlayer(playerid, "Soldier", 5000, 6);
                GivePlayerWeapon(playerid, 4, 1);
                GivePlayerWeapon(playerid, 24, 30);
                GivePlayerWeapon(playerid, 31, 200);
                SpawnPlayer(playerid);
            }
            case 1:
            {
                IsSniper[playerid] = 1;
                GameTextForPlayer(playerid, "Sniper", 5000, 6);
                GivePlayerWeapon(playerid, 3, 1);
                GivePlayerWeapon(playerid, 23, 40);
                GivePlayerWeapon(playerid, 34, 250);
                GivePlayerWeapon(playerid, 17, 20);
                SpawnPlayer(playerid);
            }
            case 2:
            {
                if(PlayerInfo[playerid][Xp] >= 30)
                {
                    IsMedic[playerid] = 1;
                    GameTextForPlayer(playerid, "Medic", 5000, 6);
                    GivePlayerWeapon(playerid, 15, 1);
                    GivePlayerWeapon(playerid, 22, 75);
                    GivePlayerWeapon(playerid, 30, 200);
                    SpawnPlayer(playerid);
                }
                else
                {
                    SendClientMessage(playerid, COLOR_RED, "ERROR: You must have 30+ XP to use this class.");
                    ShowPlayerDialog(playerid, DIALOG_SCLASS, DIALOG_STYLE_LIST, "Select Class", "Soldier (0 XP)\nSniper (0 XP)\nMedic (30 XP)\nEngineer (75 XP)\nPilot (120 XP)\nFlamethrower (200 XP)\nSpy (310 XP)\nScout (350 XP)\nCargo plane Driver (500 XP)\nSupply Helicopter Driver (630 XP)\nGeneral (800 XP)\nVIP (1+ VIP Points)\nAdmin (Admin level 1+)\nOwner (Level 10)", "Go!", "");
                }
            }
            case 3:
            {
                if(PlayerInfo[playerid][Xp] >= 145)
                {
                    IsEngineer[playerid] = 1;
                    GameTextForPlayer(playerid, "Engineer", 5000, 6);
                    GivePlayerWeapon(playerid, 5, 1);
                    GivePlayerWeapon(playerid, 27, 50);
                    GivePlayerWeapon(playerid, 31, 200);
                    GivePlayerWeapon(playerid, 43, 40);
                    SpawnPlayer(playerid);
                }
                else
                {
                    SendClientMessage(playerid, COLOR_RED, "ERROR: You must have 75+ XP to use this class.");
                    ShowPlayerDialog(playerid, DIALOG_SCLASS, DIALOG_STYLE_LIST, "Select Class", "Soldier (0 XP)\nSniper (0 XP)\nMedic (30 XP)\nEngineer (75 XP)\nPilot (120 XP)\nFlamethrower (200 XP)\nSpy (310 XP)\nScout (350 XP)\nCargo plane Driver (500 XP)\nSupply Helicopter Driver (630 XP)\nGeneral (800 XP)\nVIP (1+ VIP Points)\nAdmin (Admin level 1+)\nOwner (Level 10)", "Go!", "");
                }
            }
            case 4:
            {
                if(PlayerInfo[playerid][Xp] >= 170)
                {
                    IsPilot[playerid] = 1;
                    GameTextForPlayer(playerid, "Pilot", 5000, 6);
                    GivePlayerWeapon(playerid, 22, 60);
                    GivePlayerWeapon(playerid, 30, 200);
                    GivePlayerWeapon(playerid, 46, 1);
                    SpawnPlayer(playerid);
                }
                else
                {
                    SendClientMessage(playerid, COLOR_RED, "ERROR: You must have 120+ XP to use this class.");
                    ShowPlayerDialog(playerid, DIALOG_SCLASS, DIALOG_STYLE_LIST, "Select Class", "Soldier (0 XP)\nSniper (0 XP)\nMedic (30 XP)\nEngineer (75 XP)\nPilot (120 XP)\nFlamethrower (200 XP)\nSpy (310 XP)\nScout (350 XP)\nCargo plane Driver (500 XP)\nSupply Helicopter Driver (630 XP)\nGeneral (800 XP)\nVIP (1+ VIP Points)\nAdmin (Admin level 1+)\nOwner (Level 10)", "Go!", "");
                }
            }
            case 5:
            {
                if(PlayerInfo[playerid][Xp] >= 200)
                {
                    IsFlamethrower[playerid] = 1;
                    GameTextForPlayer(playerid, "Flamethrower", 5000, 6);
                    GivePlayerWeapon(playerid, 18, 20);
                    GivePlayerWeapon(playerid, 24, 75);
                    GivePlayerWeapon(playerid, 31, 200);
                    GivePlayerWeapon(playerid, 37, 350);
                    SpawnPlayer(playerid);
                }
                else
                {
                    SendClientMessage(playerid, COLOR_RED, "ERROR: You must have 200+ XP to use this class.");
                    ShowPlayerDialog(playerid, DIALOG_SCLASS, DIALOG_STYLE_LIST, "Select Class", "Soldier (0 XP)\nSniper (0 XP)\nMedic (30 XP)\nEngineer (75 XP)\nPilot (120 XP)\nFlamethrower (200 XP)\nSpy (310 XP)\nScout (350 XP)\nCargo plane Driver (500 XP)\nSupply Helicopter Driver (630 XP)\nGeneral (800 XP)\nVIP (1+ VIP Points)\nAdmin (Admin level 1+)\nOwner (Level 10)", "Go!", "");
                }
            }
            case 6:
            {
                if(PlayerInfo[playerid][Xp] >= 310)
                {
                    IsSpy[playerid] = 1;
                    GameTextForPlayer(playerid, "Spy", 5000, 6);
                    GivePlayerWeapon(playerid, 15, 1);
                    GivePlayerWeapon(playerid, 23, 50);
                    GivePlayerWeapon(playerid, 31, 200);
                    ShowPlayerDialog(playerid, DIALOG_SSTEAM, DIALOG_STYLE_LIST, "Select Disguise Team", "Delta Force (USA)\nSpetsnaz (Russia)\nGIGN (France)\nItalian Army (Italy)\nJapan Self Defense Forces (Japan)", "Select", "Back");
                }
                else
                {
                    SendClientMessage(playerid, COLOR_RED, "ERROR: You must have 310+ XP to use this class.");
                    ShowPlayerDialog(playerid, DIALOG_SCLASS, DIALOG_STYLE_LIST, "Select Class", "Soldier (0 XP)\nSniper (0 XP)\nMedic (30 XP)\nEngineer (75 XP)\nPilot (120 XP)\nFlamethrower (200 XP)\nSpy (310 XP)\nScout (350 XP)\nCargo plane Driver (500 XP)\nSupply Helicopter Driver (630 XP)\nGeneral (800 XP)\nVIP (1+ VIP Points)\nAdmin (Admin level 1+)\nOwner (Level 10)", "Go!", "");
                }
            }
            case 7:
            {
                if(PlayerInfo[playerid][Xp] >= 350)
                {
                    IsScout[playerid] = 1;
                    GameTextForPlayer(playerid, "Scout", 5000, 6);
                    GivePlayerWeapon(playerid, 4, 1);
                    GivePlayerWeapon(playerid, 23, 75);
                    GivePlayerWeapon(playerid, 29, 130);
                    GivePlayerWeapon(playerid, 31, 200);
                    SpawnPlayer(playerid);
                }
                else
                {
                    SendClientMessage(playerid, COLOR_RED, "ERROR: You must have 350+ XP to use this class.");
                    ShowPlayerDialog(playerid, DIALOG_SCLASS, DIALOG_STYLE_LIST, "Select Class", "Soldier (0 XP)\nSniper (0 XP)\nMedic (30 XP)\nEngineer (75 XP)\nPilot (120 XP)\nFlamethrower (200 XP)\nSpy (310 XP)\nScout (350 XP)\nCargo plane Driver (500 XP)\nSupply Helicopter Driver (630 XP)\nGeneral (800 XP)\nVIP (1+ VIP Points)\nAdmin (Admin level 1+)\nOwner (Level 10)", "Go!", "");
                }
            }
            case 8:
            {
                if(PlayerInfo[playerid][Xp] >= 500)
                {
                    IsPlaneDriver[playerid] = 1;
                    GameTextForPlayer(playerid, "Cargo Plane Driver", 5000, 6);
                    GivePlayerWeapon(playerid, 26, 80);
                    GivePlayerWeapon(playerid, 29, 75);
                    GivePlayerWeapon(playerid, 33, 130);
                    GivePlayerWeapon(playerid, 31, 200);
                    GivePlayerWeapon(playerid, 46, 1);
                    SpawnPlayer(playerid);
                }
                else
                {
                    SendClientMessage(playerid, COLOR_RED, "ERROR: You must have 500+ XP to use this class.");
                    ShowPlayerDialog(playerid, DIALOG_SCLASS, DIALOG_STYLE_LIST, "Select Class", "Soldier (0 XP)\nSniper (0 XP)\nMedic (30 XP)\nEngineer (75 XP)\nPilot (120 XP)\nFlamethrower (200 XP)\nSpy (310 XP)\nScout (350 XP)\nCargo plane Driver (500 XP)\nSupply Helicopter Driver (630 XP)\nGeneral (800 XP)\nVIP (1+ VIP Points)\nAdmin (Admin level 1+)\nOwner (Level 10)", "Go!", "");
                }
            }
            case 9:
            {
                if(PlayerInfo[playerid][Xp] >= 630)
                {
                    IsHeliDriver[playerid] = 1;
                    GameTextForPlayer(playerid, "Helicopter Plane Driver", 5000, 6);
                    GivePlayerWeapon(playerid, 26, 80);
                    GivePlayerWeapon(playerid, 29, 75);
                    GivePlayerWeapon(playerid, 33, 130);
                    GivePlayerWeapon(playerid, 31, 200);
                    GivePlayerWeapon(playerid, 46, 1);
                    SpawnPlayer(playerid);
                }
                else
                {
                    SendClientMessage(playerid, COLOR_RED, "ERROR: You must have 630+ XP to use this class.");
                    ShowPlayerDialog(playerid, DIALOG_SCLASS, DIALOG_STYLE_LIST, "Select Class", "Soldier (0 XP)\nSniper (0 XP)\nMedic (30 XP)\nEngineer (75 XP)\nPilot (120 XP)\nFlamethrower (200 XP)\nSpy (310 XP)\nScout (350 XP)\nCargo plane Driver (500 XP)\nSupply Helicopter Driver (630 XP)\nGeneral (800 XP)\nVIP (1+ VIP Points)\nAdmin (Admin level 1+)\nOwner (Level 10)", "Go!", "");
                }
            }
            case 10:
            {
                if(PlayerInfo[playerid][Xp] >= 800)
                {
                    IsGeneral[playerid] = 1;
                    GameTextForPlayer(playerid, "General", 5000, 6);
                    GivePlayerWeapon(playerid, 26, 80);
                    GivePlayerWeapon(playerid, 29, 75);
                    GivePlayerWeapon(playerid, 33, 130);
                    GivePlayerWeapon(playerid, 31, 200);
                    GivePlayerWeapon(playerid, 46, 1);
                    SpawnPlayer(playerid);
                }
                else
                {
                    SendClientMessage(playerid, COLOR_RED, "ERROR: You must have 800+ XP to use this class.");
                    ShowPlayerDialog(playerid, DIALOG_SCLASS, DIALOG_STYLE_LIST, "Select Class", "Soldier (0 XP)\nSniper (0 XP)\nMedic (30 XP)\nEngineer (75 XP)\nPilot (120 XP)\nFlamethrower (200 XP)\nSpy (310 XP)\nScout (350 XP)\nCargo plane Driver (500 XP)\nSupply Helicopter Driver (630 XP)\nGeneral (800 XP)\nVIP (1+ VIP Points)\nAdmin (Admin level 1+)\nOwner (Level 10)", "Go!", "");
                }
            }
            case 11:
            {
                if(PlayerInfo[playerid][Points] >= 1)
                {
                    IsVIP[playerid] = 1;
                    GameTextForPlayer(playerid, "~y~VIP", 5000, 6);
                    GivePlayerWeapon(playerid, 24, 80);
                    GivePlayerWeapon(playerid, 32, 75);
                    GivePlayerWeapon(playerid, 31, 150);
                    GivePlayerWeapon(playerid, 39, 200);
                    GivePlayerWeapon(playerid, 40, 1);
                    SpawnPlayer(playerid);
                }
                else
                {
                    SendClientMessage(playerid, COLOR_RED, "ERROR: You must have 1+ VIP Points to use this class.");
                    ShowPlayerDialog(playerid, DIALOG_SCLASS, DIALOG_STYLE_LIST, "Select Class", "Soldier (0 XP)\nSniper (0 XP)\nMedic (30 XP)\nEngineer (75 XP)\nPilot (120 XP)\nFlamethrower (200 XP)\nSpy (310 XP)\nScout (350 XP)\nCargo plane Driver (500 XP)\nSupply Helicopter Driver (630 XP)\nGeneral (800 XP)\nVIP (1+ VIP Points)\nAdmin (Admin level 1+)\nOwner (Level 10)", "Go!", "");
                }
            }
            case 12:
            {
                if(PlayerInfo[playerid][Admin] >= 1)
                {
                    IsAdmin[playerid] = 1;
                    GameTextForPlayer(playerid, "~r~Administrator", 5000, 6);
                    GivePlayerWeapon(playerid, 24, 80);
                    GivePlayerWeapon(playerid, 28, 110);
                    GivePlayerWeapon(playerid, 30, 130);
                    GivePlayerWeapon(playerid, 37, 200);
                    GivePlayerWeapon(playerid, 16, 5);
                    SpawnPlayer(playerid);
                }
                else
                {
                    SendClientMessage(playerid, COLOR_RED, "ERROR: You must have Admin level 1+ to use this class.");
                    ShowPlayerDialog(playerid, DIALOG_SCLASS, DIALOG_STYLE_LIST, "Select Class", "Soldier (0 XP)\nSniper (0 XP)\nMedic (30 XP)\nEngineer (75 XP)\nPilot (120 XP)\nFlamethrower (200 XP)\nSpy (310 XP)\nScout (350 XP)\nCargo plane Driver (500 XP)\nSupply Helicopter Driver (630 XP)\nGeneral (800 XP)\nVIP (1+ VIP Points)\nAdmin (Admin level 1+)\nOwner (Level 10)", "Go!", "");
                }
            }
            case 13:
            {
                if(PlayerInfo[playerid][Admin] == 10)
                {
                    IsOwner[playerid] = 1;
                    GameTextForPlayer(playerid, "~r~Owner", 5000, 6);
                    GivePlayerWeapon(playerid, 22, 999999);
                    GivePlayerWeapon(playerid, 32, 999999);
                    GivePlayerWeapon(playerid, 31, 999999);
                    GivePlayerWeapon(playerid, 38, 999999);
                    GivePlayerWeapon(playerid, 16, 999999);
                    SpawnPlayer(playerid);
                }
                else
                {
                    SendClientMessage(playerid, COLOR_RED, "ERROR: You must be owner to use this class.");
                    ShowPlayerDialog(playerid, DIALOG_SCLASS, DIALOG_STYLE_LIST, "Select Class", "Soldier (0 XP)\nSniper (0 XP)\nMedic (30 XP)\nEngineer (75 XP)\nPilot (120 XP)\nFlamethrower (200 XP)\nSpy (310 XP)\nScout (350 XP)\nCargo plane Driver (500 XP)\nSupply Helicopter Driver (630 XP)\nGeneral (800 XP)\nVIP (1+ VIP Points)\nAdmin (Admin level 1+)\nOwner (Level 10)", "Go!", "");
                }
            }
        }
    }

    //SPY - Select Team
    if(dialogid == DIALOG_SSTEAM)
    {
        if(response)
        {
            switch(listitem)
            {
                case 0:
                {
                    SetPlayerColor(playerid, COLOR_BLUE);
                    GameTextForPlayer(playerid, "~b~DELTA FORCE", 7500, 6);
                    SetPlayerSkin(playerid, SKIN_USA);
                }
                case 1:
                {
                    SetPlayerColor(playerid, COLOR_RED);
                    GameTextForPlayer(playerid, "~r~SPETSNAZ", 7500, 6);
                    SetPlayerSkin(playerid, SKIN_RUSSIA);
                }
                case 2:
                {
                    SetPlayerColor(playerid, COLOR_GREEN);
                    GameTextForPlayer(playerid, "~g~GIGN", 7500, 6);
                    SetPlayerSkin(playerid, SKIN_GIGN);
                }
                case 3:
                {
                    SetPlayerColor(playerid, COLOR_AQUA);
                    GameTextForPlayer(playerid, "ITALIAN ARMY", 7500, 6);
                    SetPlayerSkin(playerid, SKIN_IA);
                }
                case 4:
                {
                    SetPlayerColor(playerid, 0xFF800096);
                    GameTextForPlayer(playerid, "Japan Self Defense Forces", 7500, 6);
                    SetPlayerSkin(playerid, SKIN_JSDF);
                }
            }
        }
        else
        {
            //The player has pressed "Select".
            switch(listitem)
            {
                case 0:
                {
                    //Selected Item: "Delta Force (USA)"
                }
                case 1:
                {
                    //Selected Item: "Spetsnaz (Russia)"
                }
                case 2:
                {
                    //Selected Item: "GIGN (France)"
                }
                case 3:
                {
                    //Selected Item: "Italian Army (Italy)"
                }
                case 4:
                {
                    //Selected Item: "Japan Self Defense Forces (Japan)"
                }
            }
        }
    }
    
    if(dialogid == DIALOG_LOGIN)
	{
	    new name[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, name, sizeof(name));
		if(response)
		{
		    if(udb_hash(inputtext) == PlayerInfo[playerid][Password])
		    {
				GivePlayerMoney(playerid, PlayerInfo[playerid][Cash]);
				SetPlayerScore(playerid, PlayerInfo[playerid][Score]);
				PlayerInfo[playerid][Xp] = PlayerInfo[playerid][Xp];
				printf("*** %s has logged in!", name);
				SendClientMessage(playerid, -1, "-| You have successfully logged in! |-");
			}
			else
			{
				ShowPlayerDialog(playerid, DIALOG_LOGIN_2, DIALOG_STYLE_INPUT, "Invalid Password", "\n\n\t\t{FF0000}Invalid Password\n\n\t\t{CFCC92}MWFFA\n\n\t\tWelcome to MWFFA!\n\n{FFFF00}Please enter your password to start the game!\n\n", "Join the Action", "Get Kicked");
				PlayerInfo[playerid][LoginAttempts]++;
			}
		}
		else
		{
			SendClientMessage(playerid, COLOR_RED, "You are now being kicked for not logging in!");
			printf("*** %s has been kicked for not logging in!", name);
			Kick(playerid);
		}
	}
	
	if(dialogid == DIALOG_LOGIN_2)
	{
		new name[MAX_PLAYER_NAME];
		GetPlayerName(playerid, name, sizeof(name));
		if(response)
		{
			if(udb_hash(inputtext) == PlayerInfo[playerid][Password])
		    {
				GivePlayerMoney(playerid, PlayerInfo[playerid][Cash]);
				SetPlayerScore(playerid, PlayerInfo[playerid][Score]);
				PlayerInfo[playerid][Xp] = PlayerInfo[playerid][Xp];
				printf("*** %s has logged in!", name);
				SendClientMessage(playerid, -1, "-| You have successfully logged in! |-");
			}
			else
			{
				ShowPlayerDialog(playerid, DIALOG_LOGIN_2, DIALOG_STYLE_INPUT, "Invalid Password", "\n\n\t\t{FF0000}Invalid Password\n\n\t\t{CFCC92}MWFFA\n\n\t\tWelcome to MWFFA!\n\n{FFFF00}Please enter your password to start the game!\n\n", "Join the Action", "Get Kicked");
				PlayerInfo[playerid][LoginAttempts]++;
			}
		}
		else
		{
			SendClientMessage(playerid, COLOR_RED, "You are now being kicked for not logging in!");
			printf("*** %s has been kicked for not logging in!", name);
			Kick(playerid);
		}
	}
	
	if(dialogid == DIALOG_REGISTER)
	{
		if(response)
		{
		    if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER_2, DIALOG_STYLE_INPUT, "No Password Entered", "{FF0000}You have entered no password.\n\n\t\t\t{00FF00}MWFFA\n\n\t{0000FF}Welcome on the server!\n\t{0000FF}Please register to start the game!", "Join the Action", "Get Kicked");
			new INI:File = INI_Open(UserPath(playerid));
			INI_WriteInt(File,"Password",udb_hash(inputtext));
			INI_WriteInt(File,"LoggedIn",0);
			INI_WriteInt(File,"Admin",0);
			INI_WriteInt(File,"VipPoints",0);
			INI_WriteInt(File,"Score",0);
			INI_WriteInt(File,"Money",0);
			INI_WriteInt(File,"Kills",0);
			INI_WriteInt(File,"Deaths",0);
			INI_Close(File);
		}
		else
		{
			Kick(playerid);
		}
	}
	
	if(dialogid == DIALOG_REGISTER_2)
	{
		if(response)
		{
			if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER_2, DIALOG_STYLE_INPUT, "No Password Entered", "{FF0000}You have entered no password.\n\n\t\t\t{00FF00}MWFFA\n\n\t{0000FF}Welcome on the server!\n\t{0000FF}Please register to start the game!", "Join the Action", "Get Kicked");
			new INI:File = INI_Open(UserPath(playerid));
			INI_WriteInt(File,"Password",udb_hash(inputtext));
			INI_WriteInt(File,"LoggedIn",0);
			INI_WriteInt(File,"Admin",0);
			INI_WriteInt(File,"VipPoints",0);
			INI_WriteInt(File,"Score",0);
			INI_WriteInt(File,"Money",0);
			INI_WriteInt(File,"Kills",0);
			INI_WriteInt(File,"Deaths",0);
		}
		else
		{
			Kick(playerid);
		}
	}
    return 0;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}

//================= STOCKS ================//
stock GetVehicleSpeed(const vehicleid, bool:mph = false)
{
    new Float:x, Float:y, Float:z;
    GetVehicleVelocity(vehicleid, x, y, z);

    if(mph) return floatround(((floatpower(x, 2)) + (floatpower(y, 2)) + (floatpower(z, 2))) * 100);
    else return floatround((((floatpower(x, 2)) + (floatpower(y, 2)) + (floatpower(z, 2))) * 100) * 1.6);
}

stock GivePlayerScore(playerid, amount, bool:plus = true)
{
    new score = GetPlayerScore(playerid);

    if(plus) return SetPlayerScore(playerid, score+amount);
    else return SetPlayerScore(playerid, score-amount);
}

stock IsPlayerInArea(playerid,Float:min_x,Float:min_y,Float:max_x,Float:max_y)
{
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    if((X <= max_x && X >= min_x) && (Y <= max_y && Y >= min_y)) return 1;

    return 0;
}

stock TeamColor(playerid)
{
    new color;
    new team;
    team = GetPlayerTeam(playerid);
    if(team == TEAM_DELTA)
    {
        color = 0x0000FFA0;
    }

    if(team == TEAM_SPETSNAZ)
    {
        color = 0xFF0000A0;
    }

    if(team == TEAM_GIGN)
    {
        color = 0x00FF008A;
    }

    if(team == TEAM_IA)
    {
        color = 0x00FFFF8A;
    }

    if(team == TEAM_JSDF)
    {
        color = 0x00FFFF8A;
    }
    return color;
}
//============== PUBLICS =================//
public ASKOff(playerid)
{
    PlayerInfo[playerid][Protected] = 0;
    SendClientMessage(playerid, COLOR_RED, "Anti-spawn kill off.");
    SetPlayerHealth(playerid, 100);
    SetPlayerArmour(playerid, 100.0);
    return 1;
}

//================ IRC PUBLICS ====================//
public IRC_OnConnect(botid)
{
    printf("*** IRC_OnConnect: Bot ID %d connected!", botid);
    // Join the channel
    if(botid == 1)
    {
        IRC_JoinChannel(botid, IRC_CHANNEL);
        IRC_AddToGroup(gGroupID, botid);
    }
    // Add the bot to the group
    return 1;
}

/*
    Note that this callback is executed whenever a current connection is closed
    OR whenever a connection attempt fails. Reconnecting too fast can flood the
    IRC server and possibly result in a ban. It is recommended to set up
    connection reattempts on a timer, as demonstrated here.
*/

public IRC_OnDisconnect(botid)
{
    printf("*** IRC_OnDisconnect: Bot ID %d disconnected!", botid);
    printf("*** IRC_OnDisconnect: Bot ID %d attempting to reconnect...", botid);
    // Remove the bot from the group
    IRC_RemoveFromGroup(gGroupID, botid);
    return 1;
}

public IRC_OnJoinChannel(botid, channel[])
{
    printf("*** IRC_OnJoinChannel: Bot ID %d joined channel %s!", botid, channel);
    return 1;
}

/*
    If the bot cannot immediately rejoin the channel (in the event, for example,
    that the bot is kicked and then banned), you might want to set up a timer
    here as well for rejoin attempts.
*/

public IRC_OnLeaveChannel(botid, channel[], message[])
{
    printf("*** IRC_OnLeaveChannel: Bot ID %d left channel %s (%s)!", botid, channel, message);
    IRC_JoinChannel(botid, channel);
    return 1;
}

public IRC_OnUserDisconnect(botid, user[], host[], message[])
{
    printf("*** IRC_OnUserDisconnect (Bot ID %d): User %s (%s) disconnected! (%s)", botid, user, host, message);
    return 1;
}

public IRC_OnUserJoinChannel(botid, channel[], user[], host[])
{
    printf("*** IRC_OnUserJoinChannel (Bot ID %d): User %s (%s) joined channel %s!", botid, user, host, channel);
    return 1;
}

public IRC_OnUserLeaveChannel(botid, channel[], user[], host[], message[])
{
    printf("*** IRC_OnUserLeaveChannel (Bot ID %d): User %s (%s) left channel %s (%s)!", botid, user, host, channel, message);
    return 1;
}

public IRC_OnUserNickChange(botid, oldnick[], newnick[], host[])
{
    printf("*** IRC_OnUserNickChange (Bot ID %d): User %s (%s) changed his nick to %s!", botid, oldnick, host, newnick);
    return 1;
}

public IRC_OnUserSetChannelMode(botid, channel[], user[], host[], mode[])
{
    printf("*** IRC_OnUserSetChannelMode (Bot ID %d): User %s (%s) on %s set mode: %s!", botid, user, host, channel, mode);
    return 1;
}

public IRC_OnUserSetChannelTopic(botid, channel[], user[], host[], topic[])
{
    printf("*** IRC_OnUserSetChannelTopic (Bot ID %d): User %s (%s) on %s set topic: %s!", botid, user, host, channel, topic);
    return 1;
}

public IRC_OnUserNotice(botid, recipient[], user[], host[], message[])
{
    printf("*** IRC_OnUserNotice (Bot ID %d): User %s (%s) sent notice to %s: %s", botid, user, host, recipient, message);
    return 1;
}

//=================== IRC Commands ===============//
IRCCMD:freeze(botid, channel[], user[], host[], params[])
{
    if(IRC_IsAdmin(botid, channel, user))
    {
        if(!strlen(params)) return IRC_Notice(botid, user, "*** Usage: !freeze (ID) (Reason)");
        new id;
        new Index;
        new tmp[256];
        tmp = strtok(params, Index);
        new reason;
        new string[100];
        new name[MAX_PLAYER_NAME];
        id = strval(tmp);
        reason = params[2];
        if(id == INVALID_PLAYER_ID) return IRC_Notice(botid, user, "*** Invalid player ID");
        else
        {
            GetPlayerName(id, name, sizeof(name));
            TogglePlayerControllable(id, 0);
            format(string, sizeof(string),"*** You have successfully frozen %s(%d)", name, id);
            IRC_Notice(botid, user, string);
            format(string, sizeof(string), "*** IRC Admin %s has frozen %s(%d) for reason %s", user, name, id, reason);
            IRC_GroupSay(gGroupID, IRC_CHANNEL, string);
            format(string, sizeof(string), "-| You have been frozen by IRC Admin %s for reason %s |-", user, reason);
            SendClientMessage(id, COLOR_RED, string);
            format(string, sizeof(string),"-| IRC Admin %s has frozen %s(%d) for reason %s |-", user, name, id, reason);
            SendClientMessageToAll(COLOR_GREEN, string);
        }
    }
    return 1;
}

//================== STRTOK ==================//
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}

//Area check
forward AreaCheck();
public AreaCheck()
{
    new gTeam;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInArea(i, 2438.989, 2560.181, 2782.616, 2885.098))
            {
                gTeam = GetPlayerTeam(i);
                if(EnteredArea[i] == 0)
                {
                    if(gTeam == TEAM_DELTA && CapturedBy == 1 || gTeam == TEAM_SPETSNAZ && CapturedBy == 2 || gTeam == TEAM_GIGN && CapturedBy == 3 || gTeam == TEAM_IA && CapturedBy == 4 || gTeam == TEAM_JSDF && CapturedBy == 5)
                    {
                        SendClientMessage(i, COLOR_RED, "This area has already been captured by your team!");
                        EnteredArea[i] = 1;
                        return 0;
                    }
                    else
                    {
                        SendClientMessage(i, COLOR_GREEN, "Stay in the zone for 20 seconds to capture it.");
                        GangZoneFlashForAll(Z_KACC, TeamColor(i));
                        SendClientMessageToAll(COLOR_RED, "KACC Military fuels is being taken over!");
                        TT[i] = SetTimer("TakeOver", 20000, 0);
                        return 0;
                    }
                }
            }
        }
    }

	//SF Driving School
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
	    gTeam = GetPlayerTeam(i);
	    if(IsPlayerConnected(i))
	    {
			if(IsPlayerInArea(i, -2197.686, -281.7203, -2008.414, -68.69224))
			{
			    if(EnteredArea2[i] == 0)
			    {
		            if(gTeam == TEAM_DELTA && CapturedBy2 == 1 || gTeam == TEAM_SPETSNAZ && CapturedBy2 == 2 || gTeam == TEAM_GIGN && CapturedBy2 == 3 || gTeam == TEAM_IA && CapturedBy2 == 4 || gTeam == TEAM_JSDF && CapturedBy2 == 5)
		            {
		                SendClientMessage(i, COLOR_RED, "This area is already controlled by your team!");
						EnteredArea2[i] = 1;
						return 0;
					}
					else
					{
					    SendClientMessage(i, COLOR_GREEN, "Stay in the zone for 20 seconds to capture it.");
					    GangZoneFlashForAll(Z_School, TeamColor(i));
					    EnteredArea2[i] = 1;
					    SendClientMessageToAll(COLOR_RED, "The Driving School is being taken over!");
					    T2[i] = SetTimer("TakeOver", 20000, 0);
					    return 0;
					}
				}
			}
			else
			{
			    KillTimer(T2[i]);
			    EnteredArea2[i] = 0;
			}
		}
	}
	
	//LS Ocean Docks
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
	    gTeam = GetPlayerTeam(i);
	    if(IsPlayerConnected(i))
	    {
			if(IsPlayerInArea(i, 2228.381375, -2228.381375, 2866.962306, -2813.747228))
			{
			    if(EnteredArea3[i] == 0)
			    {
		            if(gTeam == TEAM_DELTA && CapturedBy3 == 1 || gTeam == TEAM_SPETSNAZ && CapturedBy3 == 2 || gTeam == TEAM_GIGN && CapturedBy3 == 3 || gTeam == TEAM_IA && CapturedBy3 == 4 || gTeam == TEAM_JSDF && CapturedBy3 == 5)
		            {
		                SendClientMessage(i, COLOR_RED, "This area is already controlled by your team!");
						EnteredArea3[i] = 1;
						return 0;
					}
					else
					{
					    SendClientMessage(i, COLOR_GREEN, "Stay in the zone for 20 seconds to capture it.");
					    GangZoneFlashForAll(Z_DOCK, TeamColor(i));
					    EnteredArea3[i] = 1;
					    SendClientMessageToAll(COLOR_RED, "Ocean Docks is being taken over!");
					    T3[i] = SetTimer("TakeOver", 20000, 0);
					    return 0;
					}
				}
			}
			else
			{
			    KillTimer(T3[i]);
			    EnteredArea3[i] = 0;
			}
		}
	}
    return 1;
}

//Take over
forward TakeOver();
public TakeOver()
{
	//KACC Military Fuels
    for(new i = 0; i < MAX_PLAYERS; i++)
	{
	    if(IsPlayerConnected(i))
	    {
	        new gTeam;
	        gTeam = GetPlayerTeam(i);
	        if(IsPlayerInArea(i, 2438.989, 2560.181, 2782.616, 2885.098))
	        {
	            GangZoneStopFlashForAll(Z_KACC);
	            GangZoneHideForAll(Z_KACC);
	            SetPlayerScore(i, GetPlayerScore(i) + 5);
	            PlayerInfo[i][Xp] += 5;
	            GivePlayerMoney(i, 3500);
	            SendClientMessage(i, COLOR_GREEN, "You have recieved 5 XP and $3500 from the captured zone.");

	            if(gTeam == TEAM_DELTA)
	            {
	                GangZoneShowForAll(Z_KACC, COLOR_BLUE);
	                SendClientMessageToAll(-1, "Delta Force has captured KACC Military Fuels!");
					return 0;
				}
	            else if(gTeam == TEAM_SPETSNAZ)
	            {
	                GangZoneShowForAll(Z_KACC, COLOR_RED);
	                SendClientMessageToAll(-1, "Spetsnaz has captured KACC Military Fuels!");
					return 0;
	            }
	            else if(gTeam == TEAM_GIGN)
	            {
	                GangZoneShowForAll(Z_KACC, COLOR_GREEN);
	                SendClientMessageToAll(-1, "GIGN has captured KACC Military Fuels!");
					return 0;
	            }
	            else if(gTeam == TEAM_IA)
	            {
	                GangZoneShowForAll(Z_KACC, COLOR_AQUA);
	                SendClientMessageToAll(-1, "Italian Army has captured KACC Military Fuels!");
					return 0;
				}
	            else if(gTeam == TEAM_JSDF)
	            {
	                GangZoneShowForAll(Z_KACC, 0xFF800096);
	                SendClientMessageToAll(-1, "Japan Self Defense Forces has captured KACC Military Fuels!");
					return 0;
				}
	            return 0;
			}
		}
    }
    
    //SF Driving School
    for(new i = 0; i < MAX_PLAYERS; i++)
	{
	    new gTeam;
     	gTeam = GetPlayerTeam(i);
		if(IsPlayerInArea(i, -2197.686, -281.7203, -2008.414, -68.69224))
		{
			GangZoneStopFlashForAll(Z_School);
			SetPlayerScore(i, GetPlayerScore(i) + 5);
			PlayerInfo[i][Xp] += 5;
			GangZoneHideForAll(Z_School);
  			GivePlayerMoney(i, 3500);
     		SendClientMessage(i, COLOR_GREEN, "You have recieved 5 XP and $3500 from the captured zone.");
     		
			if(gTeam == TEAM_DELTA)
   			{
      			GangZoneShowForAll(Z_School, 0x0000FFA0);
  				SendClientMessageToAll(-1, "Delta Force has captured The Driving School!");
      			CapturedBy2 = 1;
      			return 0;
   			}
      		else if(gTeam == TEAM_SPETSNAZ)
        	{
         		GangZoneShowForAll(Z_School, 0xFF0000A0);
           		SendClientMessageToAll(-1, "Spetsnaz has captured The Driving School!");
             	CapturedBy2 = 2;
             	return 0;
   			}
      		else if(gTeam == TEAM_GIGN)
        	{
         		GangZoneShowForAll(Z_School, 0x00FF008A);
           		SendClientMessageToAll(-1, "GIGN has captured The Driving School!");
             	CapturedBy2 = 3;
             	return 0;
       		}
         	else if(gTeam == TEAM_IA)
          	{
           		GangZoneShowForAll(Z_School, 0x00FFFF8A);
             	SendClientMessageToAll(-1, "Italian Army has captured The Driving School!");
				CapturedBy2 = 4;
				return 0;
			}
  			else if(gTeam == TEAM_JSDF)
			{
   				GangZoneShowForAll(Z_School, 0xFF800096);
       			SendClientMessageToAll(-1, "Japan Self Defense Forces has captured The Driving School!");
				CapturedBy2 = 5;
			}
		}
	}
	
	//LS Ocean Docks
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
	    new gTeam;
	    gTeam = GetPlayerTeam(i);
	    if(IsPlayerConnected(i))
	    {
			if(IsPlayerInArea(i, 2228.381375, -2228.381375, 2866.962306, -2813.747228))
			{
			    GangZoneStopFlashForAll(Z_DOCK);
				SetPlayerScore(i, GetPlayerScore(i) + 5);
				GangZoneHideForAll(Z_DOCK);
	  			GivePlayerMoney(i, 3500);
	     		SendClientMessage(i, COLOR_GREEN, "You have recieved 5 score and $3500 from the captured zone.");

				if(gTeam == TEAM_DELTA)
	   			{
	      			GangZoneShowForAll(Z_DOCK, 0x0000FF7D);
	  				SendClientMessageToAll(-1, "Delta Force has captured Ocean Docks!");
	      			CapturedBy3 = 1;
	      			return 0;
	   			}
	      		else if(gTeam == TEAM_SPETSNAZ)
	        	{
	         		GangZoneShowForAll(Z_DOCK, 0xFF00008E);
	           		SendClientMessageToAll(-1, "Spetsnaz has captured Ocean Docks!");
	             	CapturedBy3 = 2;
	             	return 0;
	   			}
	      		else if(gTeam == TEAM_GIGN)
	        	{
	         		GangZoneShowForAll(Z_DOCK, 0x00FF007D);
	           		SendClientMessageToAll(-1, "GIGN has captured Ocean Docks!");
	             	CapturedBy3 = 3;
	             	return 0;
	       		}
	         	else if(gTeam == TEAM_IA)
	          	{
	           		GangZoneShowForAll(Z_DOCK, 0x00FFFF55);
	             	SendClientMessageToAll(-1, "Italian Army has captured Ocean Docks!");
					CapturedBy3 = 4;
					return 0;
				}
	  			else if(gTeam == TEAM_JSDF)
				{
	   				GangZoneShowForAll(Z_DOCK, 0xFF840055);
	       			SendClientMessageToAll(-1, "Japan Self Defense Forces has captured Ocean Docks!");
					CapturedBy3 = 5;
				}
			}
		}
	}
    return 1;
}

forward SaveIn(filename[],text[]);
public SaveIn(filename[],text[])
{
	new File:file;
	new filepath[256];
	new string[256];
	
	format(filepath,sizeof(filepath),"MWFFA/Logs/%s.txt",filename);
	file = fopen(filepath,io_append);
	
	format(string, sizeof(string),"%s",text);
	fwrite(file,string);
	fclose(file);
	return 1;
}

stock MessageToAdmins(color,const string[])
{
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i) == 1)
		if(PlayerInfo[i][Admin] >= 1)
	SendClientMessage(i, color, string);
	}
	return 1;
}

//Random Messages
forward RM();
public RM()
{
	new rand;
	rand = random(6);

	if(rand == 1) return SendClientMessageToAll(COLOR_GREEN, "*** Have you spotted a hacker? Use /report to report them!");
	if(rand == 2) return SendClientMessageToAll(COLOR_GREEN, "*** If you haven't visited our forums, visit now at www.sampmodernwarfare.forummotion.com");
	if(rand == 3) return SendClientMessageToAll(COLOR_GREEN, "*** Make sure to meet the owners, [MWFFA]CaptainPrice and Nirzor.");
	if(rand == 4) return SendClientMessageToAll(COLOR_GREEN, "*** Donate today and recieve plenty of features! See the forums for more details.");
	if(rand == 5) return SendClientMessageToAll(COLOR_GREEN, "*** Do you want to be an admin on MWFFA? Then once you meet the requirements, you can apply on the forums! See the forums for more details.");
	if(rand == 6) return SendClientMessageToAll(COLOR_GREEN, "*** Read /help or /commands if you need help on the server!");
	return 1;
}
Also, Here's an extra tip: It happened when i spawned on Spetsnaz team, but it didn't when I did it on Delta Force.
Reply
#2

I think you didnt create MWFFA folder and Account folder inside MWFFA.
Reply
#3

i did do that, and its an actual client crash (game crash) not server crash.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)