Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Developer: Christian
- This script is created to teach users
- the programming language used in
- sa-mp, "pawn". This script can be
- copied, used, modified or whatever
- they want, i don't care. i only want
- you to leave the credits as they are.
- */
- #include <a_samp>
- #include <dini>
- #include <zcmd>
- #include <sscanf2>
- #define COLOR_GREY 0xAFAFAFAA
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_RED 0xAA3333AA
- #define COLOR_YELLOW 0xFFFF00AA
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_BLUE 0x0000BBAA
- #define COLOR_LIGHTBLUE 0x33CCFFAA
- #define COLOR_ORANGE 0xFF9900AA
- #define COLOR_RED 0xAA3333AA
- #define COLOR_LIME 0x10F441AA
- #define COLOR_MAGENTA 0xFF00FFFF
- #define COLOR_NAVY 0x000080AA
- #define COLOR_AQUA 0xF0F8FFAA
- #define COLOR_CRIMSON 0xDC143CAA
- #define COLOR_FLBLUE 0x6495EDAA
- #define COLOR_BISQUE 0xFFE4C4AA
- #define COLOR_BLACK 0x000000AA
- #define COLOR_CHARTREUSE 0x7FFF00AA
- #define COLOR_BROWN 0XA52A2AAA
- #define COLOR_CORAL 0xFF7F50AA
- #define COLOR_GOLD 0xB8860BAA
- #define COLOR_GREENYELLOW 0xADFF2FAA
- #define COLOR_INDIGO 0x4B00B0AA
- #define COLOR_IVORY 0xFFFF82AA
- #define COLOR_LAWNGREEN 0x7CFC00AA
- #define COLOR_LIMEGREEN 0x32CD32AA //<--- Dark lime
- #define COLOR_MIDNIGHTBLUE 0X191970AA
- #define COLOR_MAROON 0x800000AA
- #define COLOR_OLIVE 0x808000AA
- #define COLOR_ORANGERED 0xFF4500AA
- #define COLOR_PINK 0xFFC0CBAA // - Light light pink
- #define COLOR_SEAGREEN 0x2E8B57AA
- #define COLOR_SPRINGGREEN 0x00FF7FAA
- #define COLOR_TOMATO 0xFF6347AA // - Tomato >:/ sounds wrong lol... well... :P
- #define COLOR_YELLOWGREEN 0x9ACD32AA //- like military green
- #define COLOR_MEDIUMAQUA 0x83BFBFAA
- #define COLOR_MEDIUMMAGENTA 0x8B008BAA // dark magenta ^^
- #define COLOR_GREY 0xAFAFAFAA
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_BRIGHTRED 0xFF0000AA
- #define COLOR_DARKRED 0xC60000FF
- #define COLOR_YELLOW 0xFFFF00AA
- #define COLOR_TAN 0xBDB76BAA
- #define COLOR_PURPLE 0x800080AA
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_LIGHTBLUE 0x33CCFFAA
- #define COLOR_ORANGE 0xFF9900AA
- #define COLOR_INDIGO 0x4B00B0AA
- #define COLOR_SYSTEM 0xa9c4e4
- #define COLOR_SANTORANGE 0xFF6C3BAA
- #define COLOR_INVIS 0xAFAFAF00
- #define COLOR_CRIMBLUE 0x3A47DEFF
- #define COLOR_WANTED 0xCC0066AA
- #define COLOR_GROVE 0x378729FF
- #define COLOR_BALLAS 0xA31D88FF
- #define COLOR_DARKGREY 0x696969FF
- #define COLOR_ERPSS 0x549852FF
- #define COLOR_L1A 0x50A2ABFF
- #define COLOR_FADE1 0xE6E6E6E6
- #define COLOR_FADE2 0xC8C8C8C8
- #define COLOR_FADE3 0xAAAAAAAA
- #define COLOR_FADE4 0x8C8C8C8C
- #define COLOR_FADE5 0x6E6E6E6E
- #define BLACK 0x000000FF
- #define DEVELOPER "Max_Exodus"
- #define VERSION "GrRp v1.0b"
- #define MAX_HOUSES 100//Lets define that we can have the max limit of our houses to 100.
- enum HouseInfo
- {
- Owner[24],
- Owned,
- Float:XPros,
- Float:YPros,
- Float:ZPros,
- VirtualWorld,
- Text3D:HouseLabel,
- }
- new HInfo[MAX_HOUSES][HouseInfo];
- new HouseInformation[MAX_HOUSES][hinfo], houseid;
- new InHouse[MAX_PLAYERS], InHouseCP[MAX_PLAYERS];
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 50
- new Score[MAX_PLAYERS];
- forward SetScore();
- #if defined FILTERSCRIPT
- public OnFilterScriptInit()
- {
- database = db_open(databasename);
- db_query(database, "CREATE TABLE IF NOT EXISTS `HOUSEINFO` (housename varchar(51), houseowner varchar(25))");
- return 1;
- }
- {
- print("\n--------------------------------------");
- print(" GrRp v1.0b by Max_Exodus");
- print("--------------------------------------\n");
- return 1;
- }
- {
- database = db_open(databasename);
- db_query(database, "CREATE TABLE IF NOT EXISTS `HOUSEINFO` (housename varchar(51), houseowner varchar(25))");
- CreateHouse("TestHouse1", 1, 2317.130615, 692.398498, 11.460937, 266.857757, 305.001586, 999.148437, 2, 1);
- CreateHouse("TestHouse2", 1, 2346.872802, 692.999267, 11.460937, 266.857757, 305.001586, 999.148437, 2, 1);
- CreateHouse("TestHouse3", 1, 2396.482666, 691.487060, 11.453125, 2196.850341, -1204.343261, 1049.023437, 6, 1);
- CreateHouse("TestHouse4", 1, 2398.476074, 735.344665, 11.460937, 2196.850341, -1204.343261, 1049.023437, 6, 1);
- CreateHouse("TestHouse5", 1, 2368.863525, 733.627502, 11.460937, 2196.850341, -1204.343261, 1049.023437, 6, 1);
- CreateHouse("TestHouse6", 1, 2013.253906, 731.041870, 11.453125, 266.857757, 305.001586, 999.148437, 5, 1);
- CreateHouse("TestHouse7", 1, 2449.826660, 742.588806, 11.460937, 266.857757, 305.001586, 999.148437, 5, 1);
- CreateHouse("TestHouse8", 1, 2449.662353, 714.210693, 11.468292, 266.857757, 305.001586, 999.148437, 5, 1);
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- #else
- main()
- {
- print("Global Roleplay");
- printf("Version: %s", VERSION);
- printf("Developer: %s", DEVELOPER);
- }
- #endif
- public SetScore()
- {
- for(new i=0;i<MAX_PLAYERS;i++)
- {
- Score[i]=GetPlayerMoney(i);
- SetPlayerScore(i, Score[i]);
- }
- return 1;
- }
- public OnGameModeInit()
- {
- // Don't use these lines if it's a filterscript
- SetGameModeText("GrRp v1.0b");
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1764.6366,-1868.6194,29.5782); // Hidden Player
- SetPlayerCameraPos(playerid, 1715.7161,-1856.6466,22.9240); // Camera Pos
- SetPlayerCameraLookAt(playerid, 1720.8245,-1866.0764,13.5719); // Camera Look At
- return 1;
- }
- forward OnPlayerRegister(playerid, step);
- public OnPlayerRegister(playerid, step)
- {
- if(step == 1)
- {
- SetPlayerPos(playerid, 1764.6366,-1868.6194,29.5782); // Hidden Player
- SetPlayerCameraPos(playerid, 1715.7161,-1856.6466,22.9240); // Camera Pos
- SetPlayerCameraLookAt(playerid, 1720.8245,-1866.0764,13.5719); // Camera Look At
- SendClientMessage(playerid, COLOR_WHITE, "==============================================================================");
- SendClientMessage(playerid, COLOR_WHITE, "Global Roleplay/Beta V 1.0.a");
- SendClientMessage(playerid, COLOR_GREY, "Welcome to Global Roleplay! We are proud to have you here.");
- SendClientMessage(playerid, COLOR_GREY, "This is the tutorial, in which you will create your account. Currently being addedin");
- SendClientMessage(playerid, COLOR_GREY, "Please wait while we load and save the required files.");
- SendClientMessage(playerid, COLOR_WHITE, "This Script Is Still Being Edited , Created By Max_Exodus.");
- SendClientMessage(playerid, COLOR_WHITE, "==============================================================================");
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new pname[128];
- GetPlayerName(playerid, pname, sizeof(pname));
- new file[128];
- format(file, sizeof(file), "Users/%s.ini", pname);
- if(!dini_Exists(file))
- {
- dini_Create(file);
- OnPlayerRegister(playerid, 1);
- }
- if(dini_Int(file, "Registered") == 0)
- {
- OnPlayerRegister(playerid, 1);
- }
- return 1;
- }
- {
- InHouse[playerid] = -1;
- InHouseCP[playerid] = -1;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/mycommand", cmdtext, true, 10) == 0)
- {
- // Do something here
- return 1;
- }
- return 0;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- 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 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)
- {
- 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 OnPlayerEnterDynamicCP(playerid, checkpointid)
- {
- for(new x; x<houseid; x++) //Loops through all current house ids.
- {
- if(HouseInformation[x][checkpointidx][0; == checkpointid) //If the entry checkpoint is entry checkpoint.
- {
- if(InHouse[playerid] != -1)
- {
- InHouse[playerid] = -1; //Sets the player to outside the house.
- return 1;
- }
- InHouseCP[playerid] = x; //Sets the InHouseCP variable.
- new Pname[24]; //Pname variable.
- GetPlayerName(playerid, Pname, 24); //Gets the players name.
- if(HouseInformation[x][owner][0] != 0 && !strcmp(Pname, HouseInformation[x][owner][0]))
- //The line above checks that the owner string has something in it, then it
- //Will compare it to our current player.
- {
- SetPlayerPos(playerid, HouseInformation[x][TelePos][0], HouseInformation[x][TelePos][1], HouseInformation[x][TelePos][2]); //Sets players position where x = houseid.
- SetPlayerInterior(playerid, HouseInformation[x][interiors]); //Sets players interior
- SetPlayerVirtualWorld(playerid, 15500000 + x); //Sets the virtual world
- //This is used if you want multiple houses per interior.
- //Sets the inhouse variable to the house he's in.
- }
- if(!HouseInformation[x][owner][0]) SendClientMessage(playerid, -1, "This house is for sale /buy to buy it!");
- //If there is no owner, it will send a message telling the player to buy it :).
- return 1;
- //We do this so the loop doesn't continue after or it tries to go for more checkpoints
- //We could alternitivly use break;
- }
- if(HouseInformation[x][checkpointidx][1] == checkpointid) //If the player enters the house exit.
- {
- if(InHouse[playerid] == -1)
- {
- InHouse[playerid] = x;
- return 1;
- }
- SetPlayerPos(playerid, HouseInformation[x][EnterPos][0], HouseInformation[x][EnterPos][1], HouseInformation[x][EnterPos][2]);
- SetPlayerInterior(playerid, 0); //Sets the player back to interior 0 (Outside)
- SetPlayerVirtualWorld(playerid, 0); //Sets the players Virtual world to 0.
- return 1;
- //We do this so the loop doesn't continue after or it tries to go for more checkpoints
- //We could alternitivly use break;
- }
- }
- return 1;
- }
- public OnPlayerLeaveDynamicCP(playerid, checkpointid)
- {
- if(InHouseCP[playerid] != - 1) InHouseCP[playerid] = -1; //Sets the players InHouseCP variable to 0.
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- COMMAND:v(playerid, params[])
- {
- // my first command, i'm so horny!
- new vehicleid, color1, color2;
- if(!sscanf(params, "iii", vehicleid, color1, color2))
- {
- new vin;
- new Float:x, Float:y, Float:z;
- GetPlayerPos(playerid, x, y, z);
- vin=CreateVehicle(vehicleid, x, y, z, 0.0, color1, color2, -1);
- PutPlayerInVehicle(playerid, vin, 0);
- }else{
- SendClientMessage(playerid, COLOR_GREY, "ERROR: This command requires: /v [vehicleid][color1][color2]");
- }
- return 1;
- }
- stock CreateHouse(HouseName[], CostP, Float:EnterX, Float:EnterY, Float:EnterZ, Float:TeleX, Float:TeleY, Float:TeleZ, Interiorx, SellP)
- {
- format(HouseInformation[houseid][Hname], 100, "%s", HouseName);
- HouseInformation[houseid][costprice] = CostP;
- HouseInformation[houseid][EnterPos][0] = EnterX;
- HouseInformation[houseid][EnterPos][1] = EnterY;
- HouseInformation[houseid][EnterPos][2] = EnterZ;
- HouseInformation[houseid][TelePos][0] = TeleX;
- HouseInformation[houseid][TelePos][1] = TeleY;
- HouseInformation[houseid][TelePos][2] = TeleZ;
- HouseInformation[houseid][sellprice] = SellP;
- HouseInformation[houseid][interiors] = Interiorx;
- format(fquery, sizeof(fquery), "SELECT houseowner FROM HOUSEINFO WHERE housename = '%s'", HouseName); //Formats the SELECT query
- queryresult = db_query(database, fquery); //Query result variable has been used to query the string above.
- if(db_num_rows(queryresult) != 0) db_get_field_assoc(queryresult, "houseowner", HouseInformation[houseid][owner], 24); //Fetches the field information db_free_result(queryresult);
- HouseInformation[houseid][checkpointidx][0] = CreateDynamicCP(EnterX, EnterY, EnterZ, 1.0);
- //CreateDynamicCP(Float:x, Float:y, Float:z, Float:size);
- HouseInformation[houseid][checkpointidx][1] = CreateDynamicCP(TeleX, TeleY, TeleZ, 1.0, 15500000+houseid, Interiorx);
- //CreateDynamicCP(Float:x, Float:y, Float:z, Float:size, worldid, interiorid);
- if(!HouseInformation[houseid][owner][0]) format(fquery, sizeof(fquery), "House Name: %s \n House Price:$%d \n Sell Price: $%d", HouseName, CostP, SellP);
- //If there is nothing in the owners variable, we check if the first cell doesn't have a character.
- else if(HouseInformation[houseid][owner][0] != 0) format(fquery, sizeof(fquery), "House Name: %s \n Owner: %s", HouseName, HouseInformation[houseid][owner]);
- //If there is something in the owners variable we check if the first cell has a character.
- HouseInformation[houseid][textid] = CreateDynamic3DTextLabel(fquery, 0xFFFFFF, EnterX, EnterY, EnterZ + 0.5, 50.0);
- //CreateDynamic3DTextLabel(const text[], color, Float:x, Float:y, Float:z, Float:drawdistance, attachedplayer = INVALID_PLAYER_ID, attachedvehicle = INVALID_VEHICLE_ID, testlos = 0, worldid = -1, interiorid = -1, playerid = -1, Float:distance = 100.0);
- houseid ++; //We go to the next free slot in our variable.
- return 1;
- }
- stock SetOwner(HouseName[], ownername[], houseids)
- {
- format(fquery, sizeof(fquery), "INSERT INTO `HOUSEINFO` (`housename`, `houseowner`) VALUES('%s', '%s')", HouseName, ownername);
- db_query(database, fquery); //Queries the SQLite database.
- format(HouseInformation[houseids][owner], 24, "%s", ownername);
- format(fquery, sizeof(fquery), "House Name: %s \n Owner: %s", HouseName, HouseInformation[houseids][owner]);
- UpdateDynamic3DTextLabelText(HouseInformation[houseids][textid], 0xFFFFFF, fquery); //Updates the text label.
- return 1;
- }
- stock DeleteOwner(HouseName[], houseids)
- {
- format(HouseInformation[houseids][owner], 24, "%s", "\0");
- format(fquery, sizeof(fquery), "DELETE FROM `HOUSEINFO` WHERE `housename` = '%s'", HouseName);
- db_query(database, fquery); //Queries the SQLite database.
- format(fquery, sizeof(fquery), "House Name: %s \n House Price:$%d \n Sell Price: $%d", HouseName, HouseInformation[houseids][costprice], HouseInformation[houseids][sellprice]);
- UpdateDynamic3DTextLabelText(HouseInformation[houseids][textid], 0xFFFFFF, fquery); //Updates the text label.
- return 1;
- }
- CMD:buy(playerid, params)
- {
- if(InHouseCP[playerid] == -1) return SendClientMessage(playerid, 0xFF0000, "You are not in any house checkpoints!");
- if(HouseInformation[InHouseCP[playerid]][owner][0] != 0) return SendClientMessage(playerid, 0xFF0000, "This house has a owner");
- if(GetPlayerMoney(playerid) < HouseInformation[InHouseCP[playerid]][costprice]) return SendClientMessage(playerid, 0xFF0000, "You don't have enough money!"); //Player has a lack of cash!
- new PlayerName[24];
- GetPlayerName(playerid, PlayerName, 24);
- format(fquery, sizeof(fquery), "SELECT `houseowner` FROM `HOUSEINFO` WHERE `houseowner` = '%s'", PlayerName); //Formats the SELECT query
- queryresult = db_query(database, fquery); //Query result variable has been used to query the string above.
- if(db_num_rows(queryresult) == MAX_HOUSES_PER_PLAYER) return SendClientMessage(playerid, 0xFF0000, "You already have the max amount of houses"); //If the player has the max houses
- db_free_result(queryresult);
- //This is the point where the player can buy the house
- SetOwner(HouseInformation[InHouseCP[playerid]][Hname], PlayerName, InHouseCP[playerid]);
- //SetOwner(HouseName[], ownername[], houseids)
- SetPlayerPos(playerid, HouseInformation[InHouseCP[playerid]][TelePos][0], HouseInformation[InHouseCP[playerid]][TelePos][1], HouseInformation[InHouseCP[playerid]][TelePos][2]); //Sets players position where InHouseCP[playerid] = houseid.
- SetPlayerInterior(playerid, HouseInformation[InHouseCP[playerid]][interiors]); //Sets players interior
- SetPlayerVirtualWorld(playerid, 15500000 + InHouseCP[playerid]); //Sets the virtual world
- GivePlayerMoney(playerid, - HouseInformation[InHouseCP[playerid]][costprice]);
- GameTextForPlayer(playerid, "House ~r~Purchased!", 3000, 3); //Tells them they have purchased a house
- return 1;
- }
- CMD:sell(playerid, params)
- {
- if(InHouse[playerid] == -1) return SendClientMessage(playerid, 0xFF0000, "You have to be inside your house to sell it!");
- new Pname[24];
- GetPlayerName(playerid, Pname, 24);
- if(strcmp(HouseInformation[InHouse[playerid]][owner], Pname) != 0) return SendClientMessage(playerid, 0xFF0000, "This is not your house!");
- //This is the point where the player can sell the house
- DeleteOwner(HouseInformation[InHouse[playerid]][Hname], InHouse[playerid]);
- //DeleteOwner(HouseName[], houseids)
- GivePlayerMoney(playerid, HouseInformation[InHouse[playerid]][sellprice]);
- SetPlayerPos(playerid, HouseInformation[InHouse[playerid]][EnterPos][0], HouseInformation[InHouse[playerid]][EnterPos][1], HouseInformation[InHouse[playerid]][EnterPos][2]);
- SetPlayerInterior(playerid, 0); //Sets the player back to interior 0 (Outside)
- SetPlayerVirtualWorld(playerid, 0); //Sets the players Virtual world to 0.
- InHouseCP[playerid] = InHouse[playerid];
- GameTextForPlayer(playerid, "House ~g~sold!", 3000, 3); //Tells them they have sold a house
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment