#include //Color Define #define COLOR_GREY 0xAFAFAFAA #define COLOR_GREEN 0x33AA33AA #define COLOR_RED 0xFF0000AA #define COLOR_YELLOW 0xFFFF00AA #define COLOR_DARKYELLOW 0xE3B515AA #define COLOR_PINK 0xFF66FFAA #define COLOR_BLUE 0x0000BBAA #define COLOR_LIGHTBLUE 0x33CCFFAA #define COLOR_DARKRED 0x660000AA #define COLOR_ORANGE 0xFF9900AA #define COLOR_WHITE 0xFFFFFFAA #define COLOR_LIGHTGREEN 0x00FF00AA //End Color Define //------------------------------------------------------------------------------ #define CP_CHEMIST 0 #define CP_ELECTRIC 1 #define CP_RICHHOUSE_1_ 2 #define CP_RICHHOUSE_2_ 3 #define P_CHEMIST 0 #define P_ELECTRIC 1 #define P_RICHHOUSE_1_ 2 #define P_RICHHOUSE_2_ 3 #define P_OFFSET 3 //------------------------------------------------------------------------------ new playerCheckpoint[MAX_PLAYERS]; #define MAX_POINTS 4 new Float:checkCoords[MAX_POINTS][4] = { {-2112.1587,-1880.4966,-1079.9663,-733.0032}, //CHEMIST {-2135.6433,-1887.8292,-1066.3611,-671.8706}, //ELECTRIC {-2688.5269,-2659.4243,894.3184,944.9646}, // RICHHOUSE_1 {-2675.2063,-2654.8101,858.9042,901.1694} // RICHHOUSE_2 // I will add a lot of properties!!! }; new Float:checkpoints[MAX_POINTS][3] = { {-1954.8829,-858.4899,32.0312}, //CHEMIST {-2541.2253,-624.2522,132.7179}, //ELECTRIC {-2671.1990,927.6693,79.7031}, // RICHHOUSE_1 {-2661.7036,876.9665,79.7738} // RICHHOUSE_2 // I will add a lot of properties!!! }; new checkpointType[MAX_POINTS] = { CP_CHEMIST, CP_ELECTRIC, CP_RICHHOUSE_1_, CP_RICHHOUSE_2_, // I will add a lot of properties!!! }; #define MAX_PROPERTIES 4 new propertyNames[MAX_PROPERTIES][100] = { "Chemist Studios", "Electric Station", "Villa Brey", "Sewayeou" // I will add a lot of properties!!! }; new propertyValues[MAX_PROPERTIES] = { 100000000, 355000000, 1000000, 500000 // I will add a lot of properties!!! }; new propertyEarnings[MAX_PROPERTIES] = { 50000, 90000, -6000, -2000 // I will add a lot of properties!!! }; new propertyOwner[MAX_PROPERTIES] = {999,999,999,999};// numer of prop main() { print("\n----------------------------------"); print(" This is a blank GameModeScript"); print("----------------------------------\n"); } public OnGameModeInit() { print("GameModeInit()"); SetGameModeText("Blank Script"); AddPlayerClass(0, -2541.2253,-624.2522,132.7179, 269.1425, 22, 5677,38, 8888, 29, 45454); AddStaticVehicle(478, -2541.2253,-628.2522,135.7179,random(360), 0, 0); AddStaticVehicle(478, -2541.2253,-628.2522,155.7179,random(360), 0, 0); AddStaticVehicle(478, -2541.2253,-628.2522,145.7179,random(360), 0, 0); AddStaticVehicle(478, -2541.2253,-628.2522,136.7179,random(360), 0, 0); AddStaticVehicle(478, -2541.2253,-638.2522,135.7179,random(360), 0, 0); AddStaticVehicle(478, -2521.2253,-628.2522,155.7179,random(360), 0, 0); AddStaticVehicle(478, -2501.2253,-628.2522,145.7179,random(360), 0, 0); AddStaticVehicle(478, -2541.2253,-618.2522,136.7179,random(360), 0, 0); SetTimer("PropertyScoreUpdate", 40005, 1); SetTimer("checkpointUpdate", 1100, 1); 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); return 1; } public OnGameModeExit() { print("GameModeExit()"); return 1; } public OnPlayerConnect(playerid) { printf("OnPlayerConnect(%d)", playerid); playerCheckpoint[playerid]=999; GivePlayerMoney(playerid, 10000000); return 1; } public OnPlayerDisconnect(playerid) { for(new i = 0; i < MAX_PROPERTIES; i++) { if(propertyOwner[i]==playerid) { propertyOwner[i] = 999; GivePlayerMoney(playerid, propertyValues[i]); } } } public OnPlayerSpawn(playerid) { printf("OnPlayerSpawn(%d)", playerid); return 1; } public OnPlayerDeath(playerid, killerid, reason) { printf("OnPlayerDeath(%d, %d, %d)", playerid, killerid, reason); return 1; } public OnVehicleSpawn(vehicleid) { printf("OnVehicleSpawn(%d)", vehicleid); 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[]) { new cmd[256]; new idx; cmd = strtok(cmdtext, idx); new giveplayer[MAX_PLAYER_NAME]; new property=999; new string[512]; if(strcmp(cmd, "/buy", true) == 0) { if(IsPlayerInCheckpoint(playerid)) { switch (playerCheckpoint[playerid]) { case CP_CHEMIST:{ property = P_CHEMIST; } case CP_ELECTRIC:{ property = P_ELECTRIC; } } 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; } //------------------- /properties if(strcmp(cmd, "/properties", true) == 0) { SendClientMessage(playerid, COLOR_GREEN, "Property Owners:"); for(new i = 0; i < MAX_PROPERTIES; i++) { if(propertyOwner[i] < 999) { GetPlayerName(propertyOwner[i], giveplayer, sizeof(giveplayer)); format(string, sizeof(string), "%d. %s - %s", i, propertyNames[i], giveplayer); } else format(string, sizeof(string), "%d. %s - None", i, propertyNames[i]); SendClientMessage(playerid, COLOR_YELLOW, string); } return 1; } // I would like to add command /sell if(strcmp(cmd, "/sell", true) == 0) { // help me ! return 1; } return 0; } public OnPlayerInfoChange(playerid) { printf("OnPlayerInfoChange(%d)"); return 1; } public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { printf("OnPlayerEnterVehicle(%d, %d, %d)", playerid, vehicleid, ispassenger); return 1; } public OnPlayerExitVehicle(playerid, vehicleid) { printf("OnPlayerExitVehicle(%d, %d)", playerid, vehicleid); return 1; } public OnPlayerStateChange(playerid, newstate, oldstate) { printf("OnPlayerStateChange(%d, %d, %d)", playerid, newstate, oldstate); return 1; } public OnPlayerEnterCheckpoint(playerid) { new string[256]; new ownplayer[MAX_PLAYER_NAME]; switch(getCheckpointType(playerid)) { case CP_CHEMIST: { SendClientMessage(playerid, COLOR_YELLOW, "You can buy the Chemist-Studious $000 with /buy."); } case CP_ELECTRIC: { SendClientMessage(playerid, COLOR_YELLOW, "You can buy the Electric-Station for $000 with /buy."); } } if(getCheckpointType(playerid)>= P_OFFSET) { format(string, sizeof(string), "You can buy the %s for $%d with /buy.", propertyNames[playerCheckpoint[playerid]-P_OFFSET], propertyValues[playerCheckpoint[playerid]-P_OFFSET]); SendClientMessage(playerid, COLOR_YELLOW, string); format(string, sizeof(string), "You will earn $%d regularly.", propertyEarnings[playerCheckpoint[playerid]-P_OFFSET]); SendClientMessage(playerid, COLOR_YELLOW, string); if(propertyOwner[playerCheckpoint[playerid]-P_OFFSET]<999) { GetPlayerName(propertyOwner[playerCheckpoint[playerid]-P_OFFSET], ownplayer, sizeof(ownplayer)); format(string, sizeof(string), "This property is currently owned by %s.", ownplayer); SendClientMessage(playerid, COLOR_RED, string); } } } public OnPlayerLeaveCheckpoint(playerid) { printf("OnPlayerLeaveCheckpoint(%d)", playerid); return 1; } public getCheckpointType(playerID) { return checkpointType[playerCheckpoint[playerID]]; } 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 PayPlayerInArea(playerID, Float:x1, Float:y1, Float:x2, Float:y2, cash) { if(IsPlayerConnected(playerID)) { new Float:X, Float:Y, Float:Z; GetPlayerPos(playerID, X, Y, Z); if(X >= x1 && X <= x2 && Y >= y1 && Y <= y2) { GivePlayerMoney(playerID, cash); return 1; } } return 0; } public checkpointUpdate() { for(new i=0; i= propertyValues[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 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); } } } 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; }