All pastes #493371 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-05-17 18:56 UTC
rendered paste body
#include <a_samp>
#include <core>
#include <float>
#include <file>
#include <string>
// for the samp stuff
#include <dutils>
// for the functions dini and dudb need
#include <dudb>
#include <Dini>
// for the userdatabase, get dudb version 2.0 for this.
#define dcmd(%1,%2,%3) if ((strcmp(%3, "/%1", true, %2+1) == 0)&&(((%3[%2+1]==0)&&(dcmd_%1(playerid,"")))||((%3[%2+1]==32)&&(dcmd_%1(playerid,%3[%2+2]))))) return 1

new playerCheckpoint[MAX_PLAYERS];
//colors ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
#define COLOR_SYSTEM 0x778899AA
#define COLOR_GREEN 0xADFF2FAA
#define COLOR_RED 0x8B0000AA
#define COLOR_ORANGE 0xFF8C00AA
#define COLOR_YELLOW 0xFFD700AA
#define COLOR_WHITE 0x778899AA
#define COLOR_GREY 0x778899AA
#define YELLOW 0xFFD700AA

// pt proprietati  ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
#define CP_BANK 	0
#define CP_PIRATE 	1
#define CP_AMMU     2
#define CP_DRAGON   3
#define CP_SEXSHOP  4
#define CP_BAR      5
#define CP_CALIGULA 6
#define CP_ZIP      7
#define CP_BINCO    8
#define CP_TATOO    9
#define CP_BOTIQUE  10

#define P_DRAGON    0
#define P_SEXSHOP   1
#define P_BAR       2
#define P_CALIGULA  3
#define P_ZIP       4
#define P_BINCO     5
#define P_TATOO     6
#define P_BOTIQUE   7

#define P_OFFSET    3

#define MAX_POINTS 11

new Float:checkCoords[MAX_POINTS][4] = {
{-36.5483,-57.9948, -17.2655,-49.2967},     //BANK
{1894.6128,1445.3431, 2084.9739,1637.8186}, //PIRATE
{284.0546,-86.4384, 302.9315,-56.6674},     //AMMUNATION
{1925.1511,968.2358, 2019.0715,1067.4276},  //DRAGON
{-115.9544,-24.2706, -99.1631,-7.1391},     //SEXSHOP
{487.6558,-88.5900, 512.0635, -67.7503},    //BAR
{2216.7971,1638.0493, 2255.2097,1714.0806}, //CALIGULA
{144.9131,-96.0927, 177.4128,-70.7923},    	//ZIP
{201.4462,-112.4556, 218.5237,-95.1238},    //BINCO
{-204.7623,-44.0326, -200.2330,-39.8128},   //TATOO
{416.7485,-84.4242, 422.6890,-74.0611}      //BOTIQUE
};

new Float:checkpoints[MAX_POINTS][3] = {
{-22.2549,-55.6575,1003.5469},
{2000.3132,1538.6012,13.5859},
{291.0004,-84.5168,1001.5156},
{1989.0619,1005.5241,994.4688},
{-103.5525,-22.4661,1000.7188},
{501.4927,-75.4323,998.7578},
{2235.5408,1679.0402,1008.3594},
{161.1875,-79.9915,1001.8047},
{207.5640,-97.8188,1005.2578},
{-203.4864,-41.2045,1002.2734},
{418.5547,-80.1667,1001.8047}
};

new checkpointType[MAX_POINTS] = {
	CP_BANK,
	CP_PIRATE,
	CP_AMMU,
	CP_DRAGON,
	CP_SEXSHOP,
	CP_BAR,
	CP_CALIGULA,
	CP_ZIP,
	CP_BINCO,
	CP_TATOO,
	CP_BOTIQUE
};

#define MAX_PROPERTIES	8

new propertyNames[MAX_PROPERTIES][32] = {
	"Four Dragons",
	"Sex Shop",
	"Shithole Bar",
	"Caligula",
	"Zip Shop",
	"Binco Shop",
	"Tatoo Parlor",
	"Botique"
};

new propertyValues[MAX_PROPERTIES] = {
	75000,
	25000,
	20000,
	100000,
	15000,
	15000,
	10000,
	20000
};

new propertyEarnings[MAX_PROPERTIES] = {
	5000,
	2000,
	1500,
	7000,
	1000,
	1000,
	700,
	1500
};

new propertyOwner[MAX_PROPERTIES] = {999,999,999,999,999,999,999,999};





new ownedcar[MAX_PLAYERS];
new owner[MAX_PLAYERS];



main()
{
	print("\n----------------------------------");
	print("  Abys RPG Server Script");
	print("----------------------------------\n");
}
new PLAYERLIST_authed[MAX_PLAYERS];


public SystemMsg(playerid,msg[]) {
   if ((IsPlayerConnected(playerid))&&(strlen(msg)>0)) {
       SendClientMessage(playerid,COLOR_SYSTEM,msg);
   }
   return 1;
}

/*
 * This function will be useful when we need the playername
 * (c) by DracoBlue 2006
 */
public PlayerName(playerid) {
  new name[255];
  GetPlayerName(playerid, name, 255);
  return name;
}


public checkpointUpdate()
{
	for(new i=0; i<MAX_PLAYERS; i++)
	{
	    if(IsPlayerConnected(i)) {
	        for(new j=0; j < MAX_POINTS; j++) {
	            if(isPlayerInArea(i, checkCoords[j])) {
	                if(playerCheckpoint[i]!=j) {
	                    DisablePlayerCheckpoint(i);
						SetPlayerCheckpoint(i, checkpoints[j][0],checkpoints[j][1],checkpoints[j][2],2);
						playerCheckpoint[i] = j;
					}
	            } else {
	            	if(playerCheckpoint[i]==j) {
	            	    DisablePlayerCheckpoint(i);
	            	    playerCheckpoint[i] = 999;
         	    	}
	            }
	        }
		}
	}
}


public isPlayerInArea(playerID, Float:data[4])
{
	new Float:X, Float:Y, Float:Z;

	GetPlayerPos(playerID, X, Y, Z);
	if(X >= data[0] && X <= data[2] && Y >= data[1] && Y <= data[3]) {
		return 1;
	}
	return 0;
}

public getCheckpointType(playerID) {
	return checkpointType[playerCheckpoint[playerID]];
}

public PropertyScoreUpdate()
{
	new owners[MAX_PROPERTIES];
	new payments[MAX_PROPERTIES];

	for(new i=0; i < MAX_PROPERTIES; i++)
	    owners[i]=999;

	for(new i=0; i < MAX_PROPERTIES; i++)
	{
		if(propertyOwner[i] < 999) {

			for(new j=0; j < MAX_PROPERTIES; j++) {
			    if(owners[j]==propertyOwner[i]) {
			        payments[j]+=propertyEarnings[i];
			        j = MAX_PROPERTIES;
			    } else if (owners[j]==999) {
					owners[j]=propertyOwner[i];
					payments[j]+=propertyEarnings[i];
			        j = MAX_PROPERTIES;
				}
			}

		}
	}

	for(new i=0; i < MAX_PROPERTIES; i++) {
		if(owners[i] < 999 && IsPlayerConnected(owners[i])) {
			new string[256];

			GivePlayerMoney(owners[i], payments[i]);

			format(string, sizeof(string), "You earned $%d from your properties.", payments[i]);
			SendClientMessage(owners[i], COLOR_GREEN, string);
		}
	}

}

public OnGameModeInit()
{

	SetGameModeText("Blank Script");
	//Class---------------------------------------------------------- ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
	AddPlayerClass(0,1686.5153,-2239.4348,13.5469,184.3173,0,0,0,0,0,0); //

//Abys cars---------------------------------------------------------------------- ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
    AddStaticVehicle(545,1248.8104,-803.6592,83.9517,181.3483,0,0); //
AddStaticVehicle(535,1243.2156,-803.9633,83.9036,179.1478,0,0); //
AddStaticVehicle(482,1254.1844,-803.8928,84.2610,178.7456,0,0); //
AddStaticVehicle(409,1249.0216,-783.7327,90.2538,359.7924,0,0); //
AddStaticVehicle(487,1291.2119,-788.2175,96.6344,359.1870,0,0); //

//other cars----------------------------------------------------------------- ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
AddStaticVehicle(560,2487.5754,-1537.7789,23.6992,357.4797,21,1); //

//necesar pt payday--------------------------------------------------------- ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
SetTimer("PayDay", 360000, 1);
	SetTimer("checkpointUpdate", 1100, 1);
	//SetTimer("PirateShipScoreUpdate", 2001, 1);
	SetTimer("PropertyScoreUpdate", 40005, 1);

	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	printf("OnPlayerRequestClass(%d, %d)", 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);
	return 1;
}

public OnGameModeExit()
{

	return 1;
}

public OnPlayerConnect(playerid)
{
	  PLAYERLIST_authed[playerid]=false;
	  GameTextForPlayer(playerid, "Abys RPG Server", 5000, 1);
	  SendClientMessage(playerid, COLOR_ORANGE, "Bun venit pe server , scrie /help pt ajutor");
	  SendClientMessage(playerid, COLOR_ORANGE, "INAINTE DE A JUCA INREGISTREAZATE");
	  SendClientMessage(playerid, COLOR_RED, "Scoate codurile marlane :))");
	  SendClientMessage(playerid, COLOR_WHITE, "Bafta pe server");
  return false;
}

public OnPlayerDisconnect(playerid)
{

  return false;
}

public OnPlayerSpawn(playerid)
{
	//Spawnpoint for abys--------------------------------------------------------------------
	new pname[24];
	GetPlayerName(playerid, pname, 24);
	if(strcmp(pname, "abys", true) == 0)
	{
		SetPlayerPos(playerid,1298.2028,-800.5502,84.1406);
		SendClientMessage(playerid, COLOR_GREEN, "Welcome to your house 'abys' !");
		SetWorldTime(0);
		GivePlayerMoney(playerid, 10000);

	}
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	printf("OnPlayerDeath(%d, %d, %d)", playerid, killerid, reason);
	return 1;
}

public OnVehicleSpawn(vehicleid)
{
//abc
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	printf("OnVehicleDeath(%d, %d)", vehicleid, killerid);
	return 1;
}

public OnPlayerText(playerid)
{
	printf("OnPlayerText(%d)", playerid);
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	// commanda /help ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
	if (strcmp(cmdtext, "/help", true)==0)
	{
	    SendClientMessage(playerid, COLOR_YELLOW, "*****( WWW.x-games.TK)*****");
	    SendClientMessage(playerid, COLOR_YELLOW, "Nui prea greu , e un simplu server RPG");
	    SendClientMessage(playerid, COLOR_YELLOW, "Scrie /commands pentru a vedea commenzile");
	    SendClientMessage(playerid, COLOR_YELLOW, "Oblicatoriu dati /rules pentru a vedea regulile");
        SendClientMessage(playerid, COLOR_YELLOW, "Inregitrativa inainte de a intra in jok");
	    SendClientMessage(playerid, COLOR_YELLOW, "Dute la punctu rosu de pe harta ca sa castigi bani");
	}
	//commanda /commands  ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
		if (strcmp(cmdtext, "/commands", true)==0)
	{
	    SendClientMessage(playerid, COLOR_YELLOW, "*****( WWW.x-games.TK)*****");
	    SendClientMessage(playerid, COLOR_YELLOW, "/xregister /xlogin - account help");
	    SendClientMessage(playerid, COLOR_YELLOW, "/help /rules /commands /dive /admin /lock");
	    SendClientMessage(playerid, COLOR_YELLOW, "/unlock /buycar /callmycar /carservice /clearcar /time");
	}
	//commanda /rules  ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
			if (strcmp(cmdtext, "/rules", true)==0)
	{
	    SendClientMessage(playerid, COLOR_YELLOW, "*****( WWW.x-games.TK)*****");
	    SendClientMessage(playerid, COLOR_RED, "Atentie , este server RPG");
	    SendClientMessage(playerid, COLOR_RED, "Nu omora , fura masini sau altele sau vei fi bagat la inchisoare");
	    SendClientMessage(playerid, COLOR_RED, "Nu faci asta in viata reala , shi in special FARA CODURI");
	}
//dcmd(login,5,cmdtext); // because login has 5 characters
//  dcmd(register,8,cmdtext); // because register has 8 characters

  // /dive  ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
  if(strcmp(cmdtext, "/dive", true) == 0) {
if (GetPlayerMoney(playerid) > 999){
GivePlayerMoney(playerid,-1000);
new Float:x;
new Float:y;
new Float:z;
GivePlayerWeapon(playerid,46,1);
GetPlayerPos(playerid,x,y,z);
SetPlayerPos(playerid,x,y,z+500);
GameTextForPlayer(playerid,"Diiiive.",2000,5);
}
else{
SendClientMessage(playerid,COLOR_RED,"Not enough cash.");
}
return 1;
	}
	// /lock  ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
		if (strcmp(cmdtext, "/lock", true)==0)
		{
			if(IsPlayerInAnyVehicle(playerid))
			{
				new State=GetPlayerState(playerid);
				if(State!=PLAYER_STATE_DRIVER)
				{
					SendClientMessage(playerid,0xFFFF00AA,"You can only lock the doors as the driver.");
					return 1;
				}
				new i;
				for(i=0;i<MAX_PLAYERS;i++)
				{
					if(i != playerid)
					{
						SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
					}
				}
				SendClientMessage(playerid, 0xFFFF00AA, "Vehicle locked!");
		    	new Float:pX, Float:pY, Float:pZ;
				GetPlayerPos(playerid,pX,pY,pZ);
				PlayerPlaySound(playerid,1056,pX,pY,pZ);
			}
			else
			{
				SendClientMessage(playerid, 0xFFFF00AA, "You're not in a vehicle!");
			}
		return 1;
		}

// /unlock  ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -------------------------------------------------------------------------------

if (strcmp(cmdtext, "/unlock", true)==0)
	{
		if(IsPlayerInAnyVehicle(playerid))
		{
			new State=GetPlayerState(playerid);
			if(State!=PLAYER_STATE_DRIVER)
			{
				SendClientMessage(playerid,0xFFFF00AA,"You can only unlock the doors as the driver.");
				return 1;
			}
			new i;
			for(i=0;i<MAX_PLAYERS;i++)
			{
				SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0);
			}
			SendClientMessage(playerid, 0xFFFF00AA, "Vehicle unlocked!");
			new Float:pX, Float:pY, Float:pZ;
			GetPlayerPos(playerid,pX,pY,pZ);
			PlayerPlaySound(playerid,1057,pX,pY,pZ);
		}
		else
		{
			SendClientMessage(playerid, 0xFFFF00AA, "You're not in a vehicle!");
		}
	return 1;
	}
	// /buycar ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
		if (strcmp(cmdtext, "/buycar", true)==0) // to set the vehicle that you register to be teleported
	{
	    if (GetPlayerMoney(playerid) < 5000)
	    {
			SendClientMessage(playerid,YELLOW,"Sorry, you don't have enough money to buy a car.");
		}
		else
		{
			if (IsPlayerInAnyVehicle(playerid) == 1)
			{
				SetVehicleToRespawn(ownedcar[playerid]);
				ownedcar[playerid] = GetPlayerVehicleID(playerid);
				owner[ownedcar[playerid]] = playerid;
				SendClientMessage(playerid,YELLOW,"Congragulations! You have purchased a new car.");
				GivePlayerMoney(playerid,-5000);
			}
			else
			{
	            SendClientMessage(playerid,YELLOW,"Please get in a vehicle to buy it.");
			}
		}
		return 1;
	}
	// /callmycar  ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
	if (strcmp(cmdtext, "/callmycar", true)==0)
	{
	    if (ownedcar[playerid] != 0)
	    {
     	    if (GetPlayerMoney(playerid) < 500)
		    {
				SendClientMessage(playerid,YELLOW,"Sorry, you don't have enough money to use the car teleport service.");
			}
			else
			{
		        new Float:playerpos[4];
		    	GetPlayerPos(playerid,playerpos[0],playerpos[1],playerpos[2]);
		    	GetPlayerFacingAngle(playerid,playerpos[3]);
		    	SetVehicleZAngle(ownedcar[playerid],playerpos[3]+90.0);
		    	SetVehiclePos(ownedcar[playerid],playerpos[0]+3.0*floatsin(-playerpos[3],degrees),playerpos[1]+3.0*floatcos(-playerpos[3],degrees),playerpos[2]+0.5); // This one is cool that I am using trigo functions to set the vehicle just before you.
		    	SendClientMessage(playerid,YELLOW,"Thank you for using car teleport service. Your car has came.");
		    	GivePlayerMoney(playerid,-500);
			}
	    }
		return 1;
	}
	// /carservice  ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
	if (strcmp(cmdtext, "/carservice", true)==0)
{
new VehicleID, Float:X, Float:Y, Float:Z;
if (GetPlayerMoney(playerid) < 2500)
		    {
				SendClientMessage(playerid,YELLOW,"Sorry, you don't have enough money to use the car teleport service.");
			}
			else
			{
            GetPlayerPos(playerid, X, Y, Z);
 			VehicleID = GetPlayerVehicleID(playerid);
 			SetVehiclePos(VehicleID, X, Y, Z);
 			SetVehicleZAngle(VehicleID, 0);
 			GivePlayerMoney(playerid,-2500);
 			}

    return 1;
}

// /time  ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
new string[MAX_STRING];
if (strcmp(cmdtext, "/time", true)==0)
        {
            new Hours;
            new Minutes;
            new Seconds;
            new Days;
            new Months;
            new Years;
            gettime(Hours, Minutes, Seconds);
            getdate(Years, Months, Days);
            format(string, sizeof(string), "Date: %d/%d/%d, Time %d:%d:%d", Days,Months,Years,Hours,Minutes,Seconds);
                SendClientMessage(playerid,COLOR_GREEN,string);
            return 1;
}


// /cealrcar  ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
if(strcmp(cmdtext,"/clearcar",true)==0){
new vehicleid;
new vcount;
new playerstate = GetPlayerState(playerid);
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
if(!IsPlayerInAnyVehicle(playerid)){
SendClientMessage(playerid,COLOR_RED,"You are not in a vehicle");
return 1;
}
if(playerstate == PLAYER_STATE_PASSENGER){
SendClientMessage(playerid,COLOR_RED,"Passengers can't use This!");
return 1;
}
vehicleid = GetPlayerVehicleID(playerid);
for(new i=0;i<MAX_PLAYERS;i++){
if(IsPlayerConnected(playerid)){
if(IsPlayerInVehicle(i,vehicleid) && i != playerid){
vcount++;
RemovePlayerFromVehicle(i);
format(string,sizeof(string),"You have been kicked from %s's Vehicle",playername);
SendClientMessage(i,COLOR_RED,string);
}
}
}
if(vcount == 0){
SendClientMessage(playerid,COLOR_RED,"There are no passengers in your vehicle");
return 1;
}
return 1;
}
// proprietati !!!!!!!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

if(strcmp(cmdtext, "/buy", true) == 0) {
		new property=999;

		//new playerCheckpoint[MAX_PLAYERS];
		new giveplayer[MAX_PLAYERS];
		if(IsPlayerInCheckpoint(playerid)) {
			switch (playerCheckpoint[playerid]) {
				case CP_DRAGON:{
					property = P_DRAGON;
				}
				case CP_SEXSHOP:{
					property = P_SEXSHOP;
				}
				case CP_BAR:{
					property = P_BAR;
				}
				case CP_CALIGULA:{
					property = P_CALIGULA;
				}
				case CP_ZIP:{
					property = P_ZIP;
				}
				case CP_BINCO:{
					property = P_BINCO;
				}
				case CP_TATOO:{
					property = P_TATOO;
				}
				case CP_BOTIQUE:{
					property = P_BOTIQUE;
				}

		}

			if(property==999) {
				SendClientMessage(playerid, COLOR_YELLOW, "You need to be in a property checkpoint to /buy it.");
				return 1;
			}

//			property--;

			if(GetPlayerMoney(playerid) < propertyValues[property]) {
				SendClientMessage(playerid, COLOR_RED, "You don't have enough money to buy this property.");
				return 1;
			}
			if(propertyOwner[property]==playerid) {
				SendClientMessage(playerid, COLOR_RED, "You already own this property.");
				return 1;
			}

			if(propertyOwner[property] < 999) {
				GetPlayerName(playerid, giveplayer, sizeof(giveplayer));
				GivePlayerMoney(propertyOwner[property], propertyValues[property]);
				format (string, sizeof(string), "Your property, the %s, has been bought out by %s (id: %d).",propertyNames[property],giveplayer,playerid);
				SendClientMessage(propertyOwner[property], COLOR_RED, string);
			}

			GivePlayerMoney(playerid, 0-propertyValues[property]);

			propertyOwner[property]=playerid;

			format(string, sizeof(string), "You have purchased the %s!", propertyNames[property]);
			SendClientMessage(playerid, COLOR_GREEN, string);

		} else {
			SendClientMessage(playerid, COLOR_YELLOW, "You need to be in a property checkpoint to /buy it.");
			return 1;
		}


		return 1;
	}




return 1;
}

public OnPlayerInfoChange(playerid)
{
	printf("OnPlayerInfoChange(%d)");
	return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
		//nimik :D
}

/*
public OnPlayerExitVehicle(playerid, vehicleid)
{

	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{

	return 1;
}
*/
public OnPlayerEnterCheckpoint(playerid)
{
//cacat in ploaie
}




// Plata de ziii !!!!!!!!!!!!!!!!!!!!  ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
public PayDay(playerid, cash)
{
GameTextForPlayer(playerid, "~w~Pay~y~Day ~n~ ~n~ ~b~$3000.00", 700, 1);

    GivePlayerMoney(playerid, 3000);
}

public OnPlayerLeaveCheckpoint(playerid)
{

	return 1;
}