Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <mysql>
- #include <streamer>
- #include <float>
- #include <YSI\y_commands>
- #include <sscanf2>
- ///////////////////////////
- #define MAX_PROPERTIES 100
- #define MAX_CINTS 50
- #define MAX_TENANTS 50
- ///////////////////////////
- #define COLOR_3D 0x00CC00FF
- #define COLOR_3D_FREE 0xB6FC69FF
- ///////////////////////////
- #define PROP_TYPE_HOUSE 0
- #define PROP_TYPE_BUSINESS 1
- #define PROP_TYPE_APARTMENT_COMPLEX 2
- #define PROP_TYPE_FACTION_HOUSE 3
- #define PROP_TYPE_FACTION_BUSINESS 4
- #define PROP_TYPE_APARTMENT 5
- //////////////////////////
- #define MYSQL_HOST "localhost"
- #define MYSQL_USER "samp"
- #define MYSQL_PASS "samp"
- #define MYSQL_DB "sa-mp"
- //////////////////////////
- #define MSG_DOOR_HOUSE "You're at {F0E12F}%s's {FFFFFF}house door!"
- #define MSG_DOOR_BUSINESS "You're at {F0E12F}%s's door!"
- #define MSG_DOOR_APARTMENT_COMPLEX "You're at {F0E12F}%s's {FFFFFF}Apartment Complex!"
- #define MSG_DOOR_FACTION_HOUSE "You're at {F0E12F}%s's {FFFFFF}house door! ((%s))"
- #define MSG_DOOR_FACTION_BUSINESS "You're at {F0E12F}%s's door!"
- #define MSG_DOOR_APARTMENT "You're at {F0E12F}%s's apartment door!"
- #define MSG_DOOR_HOUSE_SOLD "This {F0E12F}house {FFFFFF}is for sale!"
- #define MSG_DOOR_BUSINESS_SOLD "This {F0E12F}business {FFFFFF}is for sale!"
- #define MSG_DOOR_APARTMENT_COMPLEX_SOLD "This {F0E12F}apartment complex {FFFFFF}is for sale!"
- #define MSG_DOOR_FACTION_HOUSE_SOLD "This {F0E12F}house {FFFFFF}is for sale! ((Faction))"
- #define MSG_DOOR_FACTION_BUSINESS_SOLD "This {F0E12F}business {FFFFFF}is for sale! ((Faction))"
- #define MSG_DOOR_APARTMENT_SOLD "This {F0E12F}apartment {FFFFFF}is for sale!"
- /////////////////////////
- #define DIALOG_PP 25000
- /////////////////////////
- #define quickMessage(%0); SendClientMessage(playerid,-1,%0);
- /////////////////////////
- forward dbUpdate();
- /////////////////////////// fini ///////////////////////////////////////////
- #define MaxLines (999)
- #define MaxKeys (064)
- #define Fini_GetBool(%0) (bool:strval(Fini_GetStr(%0)))
- #define Fini_GetValue(%0) (strval(Fini_GetStr(%0)))
- #define Fini_Exists(%0) (fexist(%0))
- #define Fini_GetFloat(%0) floatstr(Fini_GetStr(%0))
- #define Fini_Remove(%0) (fremove(%0))
- new
- sCacheKeys[MaxLines][MaxKeys],
- sCacheValue[MaxLines][MaxKeys],
- iLoop = 0x0,
- iFind = 0x0,
- iKeySet = 0x0,
- File:iFile = File:0,
- sTemp[MaxKeys] = " ";
- stock Fini_GetStr(sKey[])
- {
- iLoop = 0x0;
- while((sCacheKeys[iLoop][0x0]) && (iLoop < MaxLines)) {
- if(!strcmp(sCacheKeys[iLoop],sKey,false))
- return sCacheValue[iLoop];
- ++iLoop;
- }
- return sCacheKeys[0];
- }
- stock Fini_Create(sFile[])
- {
- if(Fini_Exists(sFile)) return false;
- iFile = fopen(sFile,io_write);
- return fclose(iFile);
- }
- stock Fini_OpenFile(sFile[])
- {
- iFile = fopen(sFile,io_read),
- iFind = 0x0;
- iLoop = 0x0;
- while(fread(iFile,sTemp)) {
- sTemp[strlen(sTemp) - 2] = EOS;
- iFind = strfind(sTemp,"=");
- format(sCacheValue[iLoop],MaxKeys,sTemp[iFind + 1]);
- sTemp[iFind] = EOS;
- format(sCacheKeys[iLoop],MaxKeys,sTemp);
- ++iLoop;
- }
- return fclose(iFile);
- }
- stock Fini_SaveFile(sFile[])
- {
- iFile = fopen(sFile,io_write),
- sTemp[0] = EOS;
- iLoop = 0x0;
- while((sCacheKeys[iLoop][0x0]) && (iLoop < MaxLines)) {
- format(sTemp,MaxKeys,"%s=%s\r\n",sCacheKeys[iLoop],sCacheValue[iLoop]);
- fwrite(iFile,sTemp);
- ++iLoop;
- }
- return fclose(iFile);
- }
- stock Fini_CloseFile()
- {
- sCacheKeys[0][0] = EOS;
- sCacheValue[0][0] = EOS;
- iLoop = 0x0;
- iFind = 0x0;
- iKeySet = 0x0;
- sTemp[0] = EOS;
- return true;
- }
- stock Fini_IsSet(sTag[])
- {
- iLoop = 0x0;
- while((sCacheKeys[iLoop][0x0]) && (iLoop < MaxLines)) {
- if(!strcmp(sCacheKeys[iLoop],sTag,false)) {
- return true;
- }
- iLoop++;
- }
- return false;
- }
- stock Fini_SetStr(sKey[],sValue[])
- {
- iLoop = 0x0;
- while((sCacheKeys[iLoop][0x0]) && (iLoop < MaxLines)) {
- if(!strcmp(sCacheKeys[iLoop],sKey,false)) {
- sCacheValue[iLoop][0] = EOS;
- strcat(sCacheValue[iLoop],sValue);
- iKeySet = 1;
- }
- ++iLoop;
- }
- if(!iKeySet) {
- while(sCacheKeys[iLoop][0]) iLoop++;
- strcat(sCacheValue[iLoop],sValue);
- strcat(sCacheKeys[iLoop],sKey);
- }
- return EOS;
- }
- stock Fini_SetFloat(sTag[],Float:iVal)
- {
- format(sTemp,MaxKeys,"%f",iVal);
- return Fini_SetStr(sTag,sTemp);
- }
- stock Fini_SetVal(sTag[],iVal)
- {
- format(sTemp,MaxKeys,"%d",iVal);
- return Fini_SetStr(sTag,sTemp);
- }
- stock Fini_SetBool(sTag[],bool:iVal)
- {
- format(sTemp,MaxKeys,"%d",iVal);
- return Fini_SetStr(sTag,sTemp);
- }
- //////////////////////////////////////////// Ignore: OFF ////////////////////////////////////////////////
- enum PROPERTY_INFO
- {
- Float:E_X,
- Float:E_Y,
- Float:E_Z,
- E_INT,
- E_VW,
- Float:I_X,
- Float:I_Y,
- Float:I_Z,
- I_INT,
- TYPE,
- LEVEL,
- CASHBOX,
- NAME[MAX_PLAYER_NAME],
- OWNER[MAX_PLAYER_NAME],
- CO_OWNER[MAX_PLAYER_NAME],
- SOLD,
- LOCK,
- ALARM,
- PRICE,
- USED_SLOT
- }
- enum WEAPON_SLOTS
- {
- _a[2],
- _b[2],
- _c[2],
- _d[2],
- _e[2],
- _f[2],
- _g[2],
- _h[2],
- _i[2],
- _j[2]
- }
- enum PROPERTY_STATS
- {
- DOOR,
- ALARM,
- WEAPONS[WEAPON_SLOTS],
- ADMIN_LOCKED,
- ENTRANCE_FEE
- }
- enum INTERIOR_INFO
- {
- Float:X,
- Float:Y,
- Float:Z,
- INT
- }
- new
- propertyTenants [MAX_PROPERTIES] [MAX_TENANTS] [MAX_PLAYER_NAME],
- propertyInfo [MAX_PROPERTIES] [PROPERTY_INFO],
- interiorInfo [MAX_CINTS] [INTERIOR_INFO],
- propertyStats [MAX_PROPERTIES] [PROPERTY_STATS],
- propertyCP [MAX_PROPERTIES],
- Text3D:property3D [MAX_PROPERTIES],
- loadedProperties;
- main() {}
- public OnGameModeInit()
- {
- DisableInteriorEnterExits();
- mysql_init();
- mysql_connect(MYSQL_HOST,MYSQL_USER,MYSQL_PASS,MYSQL_DB);
- loadProperties();
- loadInteriors();
- SetTimer("dbUpdate", 60*5000, true );
- return 1;
- }
- public dbUpdate()
- {
- new i = 1;
- while( i < loadedProperties )
- {
- saveProperty(i);
- printf("|--- propertyInfo[%d] was successfuly saved to the database", i );
- i++;
- }
- }
- stock loadProperties()
- {
- new query[256];
- new count = 0;
- for(new i = 1; i < MAX_PROPERTIES; i++)
- {
- format(query, sizeof(query),"SELECT * FROM propertyinfo WHERE id=%d",i);
- mysql_query(query);
- mysql_store_result();
- if(mysql_num_rows())
- if(mysql_fetch_row(query,"|")) // Splits the row
- {
- printf("\n|------ Loading Property ID: %d" , i );
- new field[22][MAX_PLAYER_NAME];
- explode(query, field, "|");
- mysql_free_result();
- count++;
- propertyInfo [i] [E_X] = floatstr( field[ 1 ] );
- propertyInfo [i] [E_Y] = floatstr( field[ 2 ] );
- propertyInfo [i] [E_Z] = floatstr( field[ 3 ] );
- propertyInfo [i] [E_INT] = strval ( field[ 4 ] );
- propertyInfo [i] [E_VW] = strval ( field[ 5 ] );
- printf("|--- Exterior Info| X: %f | Y: %f | Z: %f" , propertyInfo [i] [E_X],propertyInfo [i] [E_Y],propertyInfo [i] [E_Z] );
- printf("|--- INT: %d | VW: %d" , propertyInfo [i] [E_INT],propertyInfo [i] [E_VW] );
- propertyInfo [i] [I_X] = floatstr( field[ 6 ] );
- propertyInfo [i] [I_Y] = floatstr( field[ 7 ] );
- propertyInfo [i] [I_Z] = floatstr( field[ 8 ] );
- propertyInfo [i] [I_INT] = strval ( field[ 9 ] );
- printf("|--- Interior Info| X: %f | Y: %f | Z: %f" , propertyInfo [i] [I_X],propertyInfo [i] [I_Y],propertyInfo [i] [I_Z] );
- printf("|--- INT: %d" , propertyInfo [i] [I_INT]);
- propertyInfo [i] [TYPE] = strval ( field[ 10 ] );
- propertyInfo [i] [LEVEL] = strval ( field[ 11 ] );
- propertyInfo [i] [CASHBOX] = strval ( field[ 12 ] );
- printf("|--- Property TYPE: %d | Level: %d | Cashbox: %d" , propertyInfo [i] [TYPE] , propertyInfo [i] [LEVEL] , propertyInfo [i] [CASHBOX] );
- propertyInfo [i] [NAME] = field[ 13 ];
- propertyInfo [i] [OWNER] = field[ 14 ];
- propertyInfo [i] [CO_OWNER] = field[ 15 ];
- printf("|--- Name: %s | Owner: %s | Co-Owner: %s" , propertyInfo [i] [NAME] , propertyInfo [i] [OWNER] , propertyInfo [i] [CO_OWNER] );
- propertyInfo [i] [SOLD] = strval ( field[ 16 ] );
- propertyInfo [i] [LOCK] = strval ( field[ 17 ] );
- propertyInfo [i] [ALARM] = strval ( field[ 18 ] );
- propertyInfo [i] [PRICE] = strval ( field[ 19 ] );
- printf("|--- Sold: %b | Lock Level: %d | Alarm Level: %d | Price: %d" , propertyInfo [i] [SOLD] , propertyInfo [i] [LOCK] , propertyInfo [i] [ALARM], propertyInfo [i] [PRICE]);
- propertyInfo [i] [USED_SLOT] = true;
- ///////////////////////////////////////////////////////////
- propertyCP [i] = CreateDynamicCP(propertyInfo [i] [E_X] , propertyInfo [i] [E_Y] , propertyInfo [i] [E_Z] , 2 , propertyInfo [i] [E_VW] , propertyInfo [i] [E_INT] , -1 , 4);
- printf("|--- PROPERTYID: %d | Loaded propertyCP: ID: %d" , i , propertyCP[i] );
- ///////////////////////////////////////////////////////////
- property3D [i] = CreateDynamic3DTextLabel("Loading...",-1,propertyInfo[i][E_X],propertyInfo[i][E_Y],propertyInfo[i][E_Z],20,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,0,propertyInfo[i][E_VW],propertyInfo[i][E_INT],-1,20);
- printf("|--- PROPERTYID: %d | Loaded property3D: ID: %d" , i , property3D[i] );
- ///////////////////////////////////////////////////////////
- new temp[45];
- format( temp , 45 , "propertySystem/stats/prop_%d.ini" , i );
- if(!fexist(temp))
- {
- Fini_Create(temp);
- Fini_OpenFile(temp);
- Fini_SetVal( "DOOR" , 0 );
- Fini_SetVal( "ALARM" , 0 );
- Fini_SetVal( "ADMIN_LOCKED" , 0 );
- Fini_SetVal( "ENTRANCE_FEE" , 0 );
- new l;
- while( l <= 10 )
- {
- new str[15];
- format( str , 15 , "WEAPON%d_ID" , l );
- Fini_SetVal( str , 0 );
- format( str , 15 , "WEAPON%d_AMMO" , l );
- Fini_SetVal( str , 0 );
- l++;
- }
- Fini_SaveFile(temp);
- Fini_CloseFile();
- }
- else
- {
- Fini_OpenFile(temp);
- propertyStats[i][DOOR] = Fini_GetValue("DOOR");
- propertyStats[i][ALARM] = Fini_GetValue("ALARM");
- propertyStats[i][ADMIN_LOCKED] = Fini_GetValue("ADMIN_LOCKED");
- propertyStats[i][ENTRANCE_FEE] = Fini_GetValue("ENTRANCE_FEE");
- propertyStats[i][WEAPONS][_a][0] = Fini_GetValue("WEAPON0_ID");
- propertyStats[i][WEAPONS][_a][1] = Fini_GetValue("WEAPON0_AMMO");
- propertyStats[i][WEAPONS][_b][0] = Fini_GetValue("WEAPON1_ID");
- propertyStats[i][WEAPONS][_b][1] = Fini_GetValue("WEAPON1_AMMO");
- propertyStats[i][WEAPONS][_c][0] = Fini_GetValue("WEAPON2_ID");
- propertyStats[i][WEAPONS][_c][1] = Fini_GetValue("WEAPON2_AMMO");
- propertyStats[i][WEAPONS][_d][0] = Fini_GetValue("WEAPON3_ID");
- propertyStats[i][WEAPONS][_d][1] = Fini_GetValue("WEAPON3_AMMO");
- propertyStats[i][WEAPONS][_e][0] = Fini_GetValue("WEAPON4_ID");
- propertyStats[i][WEAPONS][_e][1] = Fini_GetValue("WEAPON4_AMMO");
- propertyStats[i][WEAPONS][_f][0] = Fini_GetValue("WEAPON5_ID");
- propertyStats[i][WEAPONS][_f][1] = Fini_GetValue("WEAPON5_AMMO");
- propertyStats[i][WEAPONS][_g][0] = Fini_GetValue("WEAPON6_ID");
- propertyStats[i][WEAPONS][_g][1] = Fini_GetValue("WEAPON6_AMMO");
- propertyStats[i][WEAPONS][_h][0] = Fini_GetValue("WEAPON7_ID");
- propertyStats[i][WEAPONS][_h][1] = Fini_GetValue("WEAPON7_AMMO");
- propertyStats[i][WEAPONS][_i][0] = Fini_GetValue("WEAPON8_ID");
- propertyStats[i][WEAPONS][_i][1] = Fini_GetValue("WEAPON8_AMMO");
- propertyStats[i][WEAPONS][_j][0] = Fini_GetValue("WEAPON9_ID");
- propertyStats[i][WEAPONS][_j][1] = Fini_GetValue("WEAPON9_AMMO");
- Fini_SaveFile(temp);
- Fini_CloseFile();
- }
- format( temp , 45 , "propertySystem/stats/prop_%d_tenants.ini" , i );
- if(!fexist(temp))
- {
- Fini_Create(temp);
- }
- else
- {
- Fini_OpenFile(temp);
- new l;
- while( l < MAX_TENANTS )
- {
- new name[20], n[5];
- format( n , sizeof(n) , "%d" , l );
- format( name , sizeof(name) , "%s" , Fini_GetStr(n) );
- propertyTenants[i][l] = name;
- l++;
- }
- Fini_CloseFile();
- }
- printf("|------ Property ID: %d Loaded" , i );
- printf("|------ and the Labels were updated!\n" , i );
- updateProperty( i );
- }
- }
- printf("################################\n\t%d Properties were loaded\n",count);
- loadedProperties = count + 1;
- }
- stock loadInteriors()
- {
- new query[256];
- new count = 0;
- for(new i; i < MAX_CINTS; i++)
- {
- format(query, sizeof(query),"SELECT * FROM interiorinfo WHERE id=%d",i);
- mysql_query(query);
- mysql_store_result();
- if(mysql_num_rows())
- if(mysql_fetch_row(query,"|")) // Splits the row
- {
- printf("\n|------ Loading Inteior ID: %d" , i );
- new field[5][25];
- explode(query, field, "|");
- mysql_free_result();
- count++;
- interiorInfo[i][X] = floatstr( field[1] );
- interiorInfo[i][Y] = floatstr( field[2] );
- interiorInfo[i][Z] = floatstr( field[3] );
- interiorInfo[i][INT] = strval ( field[4] );
- printf("|--- Interior Info: X: %f | Y: %f | Z: %f | INT: %d" , interiorInfo[i][X] , interiorInfo[i][Y] , interiorInfo[i][Z] , interiorInfo[i][INT] );
- printf("\n|------ Interior ID %d was successfuly loaded!\n\n" , i );
- }
- }
- printf("###############################################\n\t%d Custom Interiors were loaded\n",count);
- }
- stock updateProperty( propertyid )
- {
- switch( propertyInfo[propertyid][TYPE] )
- {
- case PROP_TYPE_HOUSE:
- {
- if( propertyInfo[propertyid][SOLD] )
- {
- UpdateDynamic3DTextLabelText(property3D[propertyid] , 0xE1D92DFF , "House Door");
- }
- else
- {
- new str[200];
- format( str , 200 , "{258B63}This house[{FFFFFF}%d{258B63}] is for sale!\nPrice: {FFFFFF}%d{258B63}\nLock Level: {FFFFFF}%d{258B63}\nAlarm Level: {FFFFFF}%d{258B63}\nLevel: {FFFFFF}%d{258B63}" , propertyid , propertyInfo [propertyid] [PRICE] , propertyInfo [propertyid] [LOCK] , propertyInfo [propertyid] [ALARM] , propertyInfo [propertyid] [LEVEL] );
- UpdateDynamic3DTextLabelText(property3D[propertyid] , 0x258B63FF , str);
- }
- }
- case PROP_TYPE_BUSINESS:
- {
- if( propertyInfo[propertyid][SOLD] )
- {
- UpdateDynamic3DTextLabelText(property3D[propertyid] , 0xE1D92DFF , propertyInfo [propertyid] [NAME]);
- }
- else
- {
- new str[200];
- format( str , 200 , "{258B63}This business[{FFFFFF}%d{258B63}] is for sale!\nPrice: {FFFFFF}%d{258B63}\nLock Level: {FFFFFF}%d{258B63}\nAlarm Level: {FFFFFF}%d{258B63}\nLevel: {FFFFFF}%d{258B63}" , propertyid , propertyInfo [propertyid] [PRICE] , propertyInfo [propertyid] [LOCK] , propertyInfo [propertyid] [ALARM] , propertyInfo [propertyid] [LEVEL] );
- UpdateDynamic3DTextLabelText(property3D[propertyid] , 0x258B63FF ,str);
- }
- }
- case PROP_TYPE_APARTMENT_COMPLEX:
- {
- if( propertyInfo[propertyid][SOLD] )
- {
- UpdateDynamic3DTextLabelText(property3D[propertyid] , 0xE1D92DFF , "Apartment Complex");
- }
- else
- {
- new str[200];
- format( str , 200 , "{258B63}This apartment complex[{FFFFFF}%d{258B63}] is for sale!\nPrice: {FFFFFF}%d{258B63}\nLock Level: {FFFFFF}%d{258B63}\nAlarm Level: {FFFFFF}%d{258B63}\nLevel: {FFFFFF}%d{258B63}" , propertyid , propertyInfo [propertyid] [PRICE] , propertyInfo [propertyid] [LOCK] , propertyInfo [propertyid] [ALARM] , propertyInfo [propertyid] [LEVEL] );
- UpdateDynamic3DTextLabelText(property3D[propertyid] , 0x258B63FF , str);
- }
- }
- case PROP_TYPE_FACTION_HOUSE:
- {
- if( propertyInfo[propertyid][SOLD] )
- {
- UpdateDynamic3DTextLabelText(property3D[propertyid] , 0xE1D92DFF , "House Door");
- }
- else
- {
- new str[200];
- format( str , 200 , "{258B63}This faction house[{FFFFFF}%d{258B63}] is for sale!\nPrice: {FFFFFF}%d{258B63}\nLock Level: {FFFFFF}%d{258B63}\nAlarm Level: {FFFFFF}%d{258B63}\nLevel: {FFFFFF}%d{258B63}" , propertyid , propertyInfo [propertyid] [PRICE] , propertyInfo [propertyid] [LOCK] , propertyInfo [propertyid] [ALARM] , propertyInfo [propertyid] [LEVEL] );
- UpdateDynamic3DTextLabelText(property3D[propertyid] , 0x258B63FF , str);
- }
- }
- case PROP_TYPE_FACTION_BUSINESS:
- {
- if( propertyInfo[propertyid][SOLD] )
- {
- UpdateDynamic3DTextLabelText(property3D[propertyid] , 0xE1D92DFF , propertyInfo [propertyid] [NAME]);
- }
- else
- {
- new str[200];
- format( str , 200 , "{258B63}This faction business[{FFFFFF}%d{258B63}] is for sale!\nPrice: {FFFFFF}%d{258B63}\nLock Level: {FFFFFF}%d{258B63}\nAlarm Level: {FFFFFF}%d{258B63}\nLevel: {FFFFFF}%d{258B63}" , propertyid , propertyInfo [propertyid] [PRICE] , propertyInfo [propertyid] [LOCK] , propertyInfo [propertyid] [ALARM] , propertyInfo [propertyid] [LEVEL] );
- UpdateDynamic3DTextLabelText(property3D[propertyid] , 0x258B63FF , str);
- }
- }
- case PROP_TYPE_APARTMENT:
- {
- if( propertyInfo[propertyid][SOLD] )
- {
- UpdateDynamic3DTextLabelText(property3D[propertyid] , 0xE1D92DFF , "Apartment Door");
- }
- else
- {
- new str[200];
- format( str , 200 , "{258B63}This apartment[{FFFFFF}%d{258B63}] is for sale!\nPrice: {FFFFFF}%d{258B63}\nLock Level: {FFFFFF}%d{258B63}\nAlarm Level: {FFFFFF}%d{258B63}\nLevel: {FFFFFF}%d{258B63}" , propertyid , propertyInfo [propertyid] [PRICE] , propertyInfo [propertyid] [LOCK] , propertyInfo [propertyid] [ALARM] , propertyInfo [propertyid] [LEVEL] );
- UpdateDynamic3DTextLabelText(property3D[propertyid] , 0x258B63FF , str);
- }
- }
- }
- }
- stock createPropriety( Float:x , Float:y , Float:z , interiorid , vw, type , level , cintid , lock , alarm , price)
- {
- new str[500], field[6][32];
- format( str , sizeof(str) , "SELECT * FROM interiorinfo WHERE ID=%d", cintid );
- mysql_query(str);
- mysql_store_result();
- if(mysql_num_rows()) {
- if(mysql_fetch_row(str,"|")) {
- explode(str, field, "|");
- }
- }
- mysql_free_result();
- format( str , sizeof(str) , "INSERT INTO `sa-mp`.`propertyinfo` (`ID`, `E_X`, `E_Y`, `E_Z`, `E_INT`, `E_VW`, `I_X`, `I_Y`, `I_Z`, `I_INT`, `CASHBOX`, `TYPE`, `LEVEL`, `NAME`, `OWNER`, `CO_OWNER`, `SOLD`, `LOCK`, `ALARM`, `PRICE`) \
- VALUES ('NULL', '%f', '%f', '%f', '%d', '%d', '%f', '%f', '%f', '%d', '0', '%d', '%d', '%s', '%s', '%s', '0', '%d', '%d', '%d')",
- x,y,z,interiorid,vw,floatstr( field[1] ),floatstr( field[2] ),floatstr( field[3] ),strval( field[4] ),type,level,"None","None","None",lock,alarm,price );
- //print(str);
- mysql_query(str);
- }
- stock saveProperty( propertyid )
- {
- if( propertyInfo[propertyid][USED_SLOT] == 1 )
- {
- new str[512];
- format( str , sizeof(str) , "UPDATE `sa-mp`.`propertyinfo` SET `E_X`='%f', `E_Y`='%f', `E_Z`='%f', `E_INT`='%d', `E_VW`='%d', `I_X`='%f', `I_Y`='%f', `I_Z`='%f', `I_INT`='%d', `CASHBOX`='%d', `TYPE`='%d', `LEVEL`='%d',\
- `NAME`='%s', `OWNER`='%s', `CO_OWNER`='%s', `SOLD`='%d', `LOCK`='%d', \
- `ALARM`='%d', `PRICE`='%d' WHERE `ID`='%d'",propertyInfo[propertyid][E_X],propertyInfo[propertyid][E_Y],propertyInfo[propertyid][E_Z],propertyInfo[propertyid][E_INT],propertyInfo[propertyid][E_VW],
- propertyInfo[propertyid][I_X],propertyInfo[propertyid][I_Y],propertyInfo[propertyid][I_Z],
- propertyInfo[propertyid][I_INT],propertyInfo[propertyid][CASHBOX],propertyInfo[propertyid][TYPE],propertyInfo[propertyid][LEVEL],propertyInfo[propertyid][NAME],propertyInfo[propertyid][OWNER],propertyInfo[propertyid][CO_OWNER],propertyInfo[propertyid][SOLD],
- propertyInfo[propertyid][LOCK],propertyInfo[propertyid][ALARM],propertyInfo[propertyid][PRICE], propertyid );
- mysql_query(str);
- //print(str);
- new temp[45];
- format( temp , 45 , "propertySystem/stats/prop_%d.ini" , propertyid );
- if(!fexist(temp))
- {
- Fini_OpenFile(temp);
- Fini_SetVal("DOOR",propertyStats[propertyid][DOOR]);
- Fini_SetVal("ALARM",propertyStats[propertyid][ALARM]);
- Fini_SetVal("ADMIN_LOCKED",propertyStats[propertyid][ADMIN_LOCKED]);
- Fini_SetVal("ENTRANCE_FEE",propertyStats[propertyid][ENTRANCE_FEE]);
- Fini_SaveFile(temp);
- Fini_CloseFile();
- }
- format( temp , 45 , "propertySystem/stats/prop_%d_tenants.ini" , propertyid );
- if(!fexist(temp))
- {
- new i;
- while( i < MAX_TENANTS )
- {
- Fini_OpenFile(temp);
- new name[20], n[5];
- format( n , sizeof(n) , "%d" , i );
- format( name , sizeof(name) , "%s" , propertyTenants[propertyid][i] );
- Fini_SetStr(n,name);
- i++;
- }
- Fini_SaveFile(temp);
- Fini_CloseFile();
- }
- return 1;
- }
- else return 0;
- }
- stock savePropertyStats( propertyid )
- {
- if( propertyInfo[propertyid][USED_SLOT] == 1 )
- {
- new temp[45];
- format( temp , 45 , "propertySystem/stats/prop_%d.ini" , propertyid );
- if(!fexist(temp))
- {
- Fini_OpenFile(temp);
- Fini_SetVal("DOOR",propertyStats[propertyid][DOOR]);
- Fini_SetVal("ALARM",propertyStats[propertyid][ALARM]);
- Fini_SetVal("ADMIN_LOCKED",propertyStats[propertyid][ADMIN_LOCKED]);
- Fini_SetVal("ENTRANCE_FEE",propertyStats[propertyid][ENTRANCE_FEE]);
- Fini_SaveFile(temp);
- Fini_CloseFile();
- }
- format( temp , 45 , "propertySystem/stats/prop_%d_tenants.ini" , propertyid );
- if(!fexist(temp))
- {
- new i;
- while( i < MAX_TENANTS )
- {
- Fini_OpenFile(temp);
- new name[20], n[5];
- format( n , sizeof(n) , "%d" , i );
- format( name , sizeof(name) , "%s" , propertyTenants[propertyid][i] );
- Fini_SetStr(n,name);
- i++;
- }
- Fini_SaveFile(temp);
- Fini_CloseFile();
- }
- return 1;
- }
- else return 0;
- }
- stock enterProperty( playerid )
- {
- if( GetPVarInt( playerid , "StandingAt" ) != 0 )
- {
- new p = GetPVarInt( playerid , "StandingAt" );
- if( propertyStats[p][DOOR] == 0 )
- {
- SetPVarInt( playerid , "Inside" , p );
- SetPlayerInterior( playerid , propertyInfo[p][I_INT] );
- SetPlayerPos( playerid , propertyInfo[p][I_X], propertyInfo[p][I_Y], propertyInfo[p][I_Z] );
- SetPlayerVirtualWorld( playerid , p );
- }
- if( propertyStats[p][DOOR] == 1 )
- {
- GameTextForPlayer( playerid , "~w~The door seems to be ~r~locked" , 3000 , 3 );
- PlayerPlaySound(playerid, 1135, 0, 0, 0 );
- }
- else
- {
- SetPVarInt( playerid , "Inside" , p );
- SetPlayerInterior( playerid , propertyInfo[p][I_INT] );
- SetPlayerPos( playerid , propertyInfo[p][I_X], propertyInfo[p][I_Y], propertyInfo[p][I_Z] );
- SetPlayerVirtualWorld( playerid , p );
- }
- return 1;
- }
- else return 0;
- }
- stock exitProperty( playerid )
- {
- if( GetPVarInt( playerid , "Inside" ) != 0 )
- {
- new p = GetPVarInt( playerid , "Inside" );
- if( propertyStats[p][DOOR] == 0 )
- {
- SetPVarInt( playerid , "Inside" , 0 );
- SetPlayerInterior( playerid , propertyInfo[p][E_INT] );
- SetPlayerPos( playerid , propertyInfo[p][E_X], propertyInfo[p][E_Y], propertyInfo[p][E_Z] );
- SetPlayerVirtualWorld( playerid , propertyInfo[p][E_VW] );
- }
- if( propertyStats[p][DOOR] == 1 )
- {
- GameTextForPlayer( playerid , "~w~This door seems to be ~r~locked" , 3000 , 3 );
- PlayerPlaySound(playerid, 1135, 0, 0, 0 );
- }
- else
- {
- SetPVarInt( playerid , "Inside" , 0 );
- SetPlayerInterior( playerid , propertyInfo[p][E_INT] );
- SetPlayerPos( playerid , propertyInfo[p][E_X], propertyInfo[p][E_Y], propertyInfo[p][E_Z] );
- SetPlayerVirtualWorld( playerid , propertyInfo[p][E_VW] );
- }
- return 1;
- }
- else return 0;
- }
- stock buyProperty( playerid )
- {
- if( GetPVarInt( playerid , "StandingAt" ) != 0 )
- {
- new p = GetPVarInt( playerid , "StandingAt" );
- if( propertyInfo[p][SOLD] == 0 )
- {
- if( GetPlayerMoney(playerid) >= propertyInfo[p][PRICE] )
- {
- format( propertyInfo[p][OWNER] , MAX_PLAYER_NAME , "%s" , pName( playerid , false ) );
- propertyInfo[p][SOLD] = 1;
- SendClientMessage( playerid , -1 , "You've just bought this property!" );
- SendClientMessage( playerid , -1 , " (( Type /propertyhelp to get started! ))" );
- saveProperty( p );
- updateProperty( p );
- }
- else
- {
- SendClientMessage( playerid , -1 , "You don't have that money!" );
- }
- }
- }
- }
- stock sellProperty( playerid )
- {
- if( GetPVarInt( playerid , "StandingAt" ) != 0 )
- {
- new p,
- n[MAX_PLAYER_NAME],
- o[MAX_PLAYER_NAME];
- p = GetPVarInt( playerid , "StandingAt" );
- GetPlayerName(playerid , n , MAX_PLAYER_NAME );
- format( o , sizeof(o) , "%s" , propertyInfo[p][OWNER] );
- if( strmatch( n , o ) )
- {
- if( propertyInfo[p][SOLD] == 1 )
- {
- new price = propertyInfo[p][PRICE],
- money,
- str[80];
- money = ((price/10)*8);
- propertyInfo[p][SOLD] = 0;
- format( propertyInfo[p][OWNER] , MAX_PLAYER_NAME , "None" );
- format( propertyInfo[p][CO_OWNER] , MAX_PLAYER_NAME , "None" );
- format( str , sizeof(str) , "You have just sold your property and got $%d!" , money );
- SendClientMessage( playerid , -1 , str );
- saveProperty( p );
- updateProperty( p );
- }
- else
- {
- SendClientMessage( playerid , -1 , "You can't sell this property!" );
- }
- }
- else
- {
- SendClientMessage( playerid , -1 , "You don't own this property!" );
- }
- }
- }
- /*stock rentProperty( playerid )
- {
- }*/
- stock lockProperty( playerid )
- {
- new stand,
- inside,
- p,
- owner[MAX_PLAYER_NAME];
- stand = GetPVarInt( playerid , "StandingAt" );
- inside = GetPVarInt( playerid , "Inside" );
- /* debug
- new _debug[50];
- format( _debug , sizeof(_debug) , "[STANDINGPROPERTY: %d] [INSIDEPROPERTY: %d]" , stand , inside );
- SendClientMessage( playerid , -1 , _debug );
- */
- if( inside == 0 && stand == 0 )
- {
- GameTextForPlayer( playerid , "~w~There are no ~b~locks ~w~around" , 2000 , 3 );
- }
- else
- {
- if( inside > 0 ) p = inside;
- else p = stand;
- /* debug
- format( _debug , sizeof(_debug) , "You're in propertyid [%d]" , p );
- SendClientMessage( playerid , -1 , _debug );
- */
- format( owner , sizeof(owner) , "%s" , propertyInfo[p][OWNER] );
- if( strmatch( owner , pName( playerid , false ) ) )
- {
- new dstats = propertyStats[p][DOOR];
- /* debug
- format( _debug , sizeof(_debug) , "The door stat is [%d]" , dstats );
- SendClientMessage( playerid , -1 , _debug );
- */
- if( dstats == 0 )
- {
- propertyStats[p][DOOR] = 1;
- PlayerPlaySound(playerid, 1145, 0 , 0, 0);
- GameTextForPlayer( playerid , "~w~door ~r~locked" , 2000 , 3 );
- savePropertyStats( p );
- // opened
- }
- if( dstats == 1 )
- {
- propertyStats[p][DOOR] = 0;
- PlayerPlaySound(playerid, 1145, 0 , 0, 0);
- GameTextForPlayer( playerid , "~w~door ~g~unlocked" , 2000 , 3 );
- savePropertyStats( p );
- // locked
- }
- if( dstats == 2 )
- {
- GameTextForPlayer( playerid , "~w~this door was ~r~broken ~w~down" , 2000 , 3 );
- // Broken Down
- }
- }
- // if( keys )
- else
- {
- GameTextForPlayer( playerid , "~w~where are the ~b~keys?" , 2000 , 3 );
- }
- }
- }
- stock propertyPanel( playerid )
- {
- new p = GetPVarInt( playerid , "Inside" );
- if( p == 0 )
- {
- quickMessage("You aren't at any property!");
- }
- else
- {
- if( isOwner( playerid , p ) )
- {
- ShowPlayerDialog( playerid , DIALOG_PP , DIALOG_STYLE_LIST , "property Panel" , "Set Name\nSet Entrance Price\nCashbox\nSet Co-Owner\nUpgrades\nOwning Operations" , "Select" , "Cancel" );
- }
- else
- {
- quickMessage("You don't own this property!");
- }
- }
- }
- stock isOwner( playerid , p )
- {
- new _p[MAX_PLAYER_NAME] , _o[MAX_PLAYER_NAME];
- GetPlayerName( playerid , p , sizeof(p) );
- format( owner , sizeof(owner) , "%s" , propertyInfo[p][OWNER] );
- if( strmatch( _o , _p ) )
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- stock propertyMessage( playerid , messageid )
- {
- switch( messageid )
- {
- case 0: SendClientMessage( playerid , -1 , "You aren't at {9C0A23}any {FFFFFF} entrance." );
- case 1: SendClientMessage( playerid , -1 , "You aren't at {9C0A23}any {FFFFFF} exit." );
- case 2: SendClientMessage( playerid , -1 , "You have {9C0A23}already {FFFFFF}rented this property before." );
- case 3: SendClientMessage( playerid , -1 , "This house has enough tenants!" );
- case 4: SendClientMessage( playerid , -1 , "You've successfully renter this property!" );
- }
- return 0;
- }
- public OnPlayerEnterDynamicCP(playerid, checkpointid)
- {
- new i;
- while( i < loadedProperties + 1 )
- {
- if( propertyCP[i] == checkpointid )
- {
- SetPVarInt( playerid , "StandingAt" , i );
- switch( propertyInfo[i][TYPE] )
- {
- case PROP_TYPE_HOUSE:
- {
- if(propertyInfo [i] [SOLD])
- {
- new str[100];
- format( str , 100 , MSG_DOOR_HOUSE, propertyInfo[i][OWNER] );
- SendClientMessage( playerid , -1 , str );
- }
- else
- {
- new str[100];
- format( str , 100 , MSG_DOOR_HOUSE_SOLD, propertyInfo[i][OWNER] );
- SendClientMessage( playerid , -1 , str );
- }
- break;
- }
- case PROP_TYPE_BUSINESS:
- {
- if(propertyInfo [i] [SOLD])
- {
- new str[100];
- format( str , 100 , MSG_DOOR_HOUSE, propertyInfo[i][OWNER] );
- SendClientMessage( playerid , -1 , str );
- }
- else
- {
- new str[100];
- format( str , 100 , MSG_DOOR_HOUSE_SOLD, propertyInfo[i][OWNER] );
- SendClientMessage( playerid , -1 , str );
- }
- break;
- }
- case PROP_TYPE_APARTMENT_COMPLEX:
- {
- if(propertyInfo [i] [SOLD])
- {
- new str[100];
- format( str , 100 , MSG_DOOR_APARTMENT_COMPLEX, propertyInfo[i][OWNER] );
- SendClientMessage( playerid , -1 , str );
- }
- else
- {
- new str[100];
- format( str , 100 , MSG_DOOR_APARTMENT_COMPLEX_SOLD, propertyInfo[i][OWNER] );
- SendClientMessage( playerid , -1 , str );
- }
- break;
- }
- case PROP_TYPE_FACTION_HOUSE:
- {
- if(propertyInfo [i] [SOLD])
- {
- new str[100];
- format( str , 100 , MSG_DOOR_FACTION_HOUSE, propertyInfo[i][OWNER] );
- SendClientMessage( playerid , -1 , str );
- }
- else
- {
- new str[100];
- format( str , 100 , MSG_DOOR_FACTION_HOUSE_SOLD, propertyInfo[i][OWNER] );
- SendClientMessage( playerid , -1 , str );
- }
- break;
- }
- case PROP_TYPE_FACTION_BUSINESS:
- {
- if(propertyInfo [i] [SOLD])
- {
- new str[100];
- format( str , 100 , MSG_DOOR_FACTION_BUSINESS, propertyInfo[i][OWNER] );
- SendClientMessage( playerid , -1 , str );
- }
- else
- {
- new str[100];
- format( str , 100 , MSG_DOOR_FACTION_BUSINESS_SOLD, propertyInfo[i][OWNER] );
- SendClientMessage( playerid , -1 , str );
- }
- break;
- }
- case PROP_TYPE_APARTMENT:
- {
- if(propertyInfo [i] [SOLD])
- {
- new str[100];
- format( str , 100 , MSG_DOOR_APARTMENT, propertyInfo[i][OWNER] );
- SendClientMessage( playerid , -1 , str );
- }
- else
- {
- new str[100];
- format( str , 100 , MSG_DOOR_APARTMENT_SOLD, propertyInfo[i][OWNER] );
- SendClientMessage( playerid , -1 , str );
- }
- break;
- }
- }
- }
- else i++;
- }
- }
- public OnPlayerLeaveDynamicCP(playerid, checkpointid)
- {
- if( GetPVarInt( playerid , "StandingAt" ) != 0 )
- {
- SetPVarInt( playerid , "StandingAt" , 0 );
- }
- }
- explode(const sSource[], aExplode[][], const sDelimiter[] = " ", iVertices = sizeof aExplode, iLength = sizeof aExplode[]) // Created by Westie
- {
- new
- iNode,
- iPointer,
- iPrevious = -1,
- iDelimiter = strlen(sDelimiter);
- while(iNode < iVertices)
- {
- iPointer = strfind(sSource, sDelimiter, false, iPointer);
- if(iPointer == -1)
- {
- strmid(aExplode[iNode], sSource, iPrevious, strlen(sSource), iLength);
- break;
- }
- else
- {
- strmid(aExplode[iNode], sSource, iPrevious, iPointer, iLength);
- }
- iPrevious = (iPointer += iDelimiter);
- ++iNode;
- }
- return iPrevious;
- }
- stock strmatch(const String1[], const String2[])
- {
- if ((strcmp(String1, String2, true, strlen(String2)) == 0) && (strlen(String2) == strlen(String1)))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- stock pName( playerid , togglespace )
- {
- new str[25], index;
- GetPlayerName( playerid , str , 24 );
- if( togglespace )
- {
- index = strfind( str , "_" , false );
- str[index] = 32;
- return str;
- }
- else
- {
- return str;
- }
- }
- YCMD:pd(playerid , params[] , help)
- {
- #pragma unused params
- #pragma unused help
- SetPlayerPos( playerid , 1978.76538,-1671.635131,18.545551 );
- SendClientMessage( playerid , -1 , "Você foi" );
- return 1;
- }
- YCMD:pegarumabufunfa(playerid , params[] , help)
- {
- #pragma unused help
- GivePlayerMoney( playerid , strval(params) );
- return 1;
- }
- YCMD:createhouse(playerid, params[], help)
- {
- #pragma unused help
- new Float:x,
- Float:y,
- Float:z,
- interiorid,
- vw,
- type,
- level,
- cintid,
- lock,
- alarm,
- price;
- if (sscanf(params, "dddddd", type , level , cintid , lock , alarm , price))
- {
- return SendClientMessage(playerid, 0xFF0000AA, "Usage: /createhouse [type] [level] [cintid] [lock] [alarm] [price]");
- }
- GetPlayerPos( playerid , x , y , z );
- interiorid = GetPlayerInterior( playerid );
- vw = GetPlayerVirtualWorld(playerid);
- createPropriety( x , y , z , interiorid , vw, type , level , cintid , lock , alarm , price);
- printf("|--- The administrator %s has just created a new house: %f | %f | %f", pName(playerid, true) , x, y, z );
- return 1;
- }
- YCMD:enter( playerid , params[] , help )
- {
- #pragma unused params
- #pragma unused help
- enterProperty(playerid);
- return 1;
- }
- YCMD:exit( playerid , params[] , help )
- {
- #pragma unused params
- #pragma unused help
- exitProperty(playerid);
- return 1;
- }
- YCMD:lock( playerid , params[] , help )
- {
- #pragma unused params
- #pragma unused help
- lockProperty(playerid);
- return 1;
- }
- YCMD:alock( playerid , params[] , help )
- {
- #pragma unused help
- new p,
- stat;
- if (sscanf(params, "dd", p , stat ))
- {
- return SendClientMessage(playerid, 0xFF0000AA, "Usage: (AdminLock) /alock [houseid] [1/0]");
- }
- if ( p == 0 || stat > 0 || stat > 2 )
- {
- return SendClientMessage(playerid, 0xFF0000AA, "Usage: (AdminLock) /alock [houseid] [1/0] (2if)");
- }
- else
- {
- if( stat == 0 )
- {
- propertyStats[p][DOOR] = stat;
- new str[80];
- format( str , 80 , "You have just {5EAF03}unlocked {FFFFFF}property id %d" , p );
- SendClientMessage(playerid, 0xFF0000AA, str);
- }
- if( stat == 1 )
- {
- propertyStats[p][DOOR] = stat;
- new str[80];
- format( str , 80 , "You have just {D32C2C}locked {FFFFFF}property id %d" , p );
- SendClientMessage(playerid, 0xFF0000AA, str);
- }
- if( stat == 2 )
- {
- propertyStats[p][DOOR] = stat;
- new str[80];
- format( str , 80 , "You have just the property(%d) stats to {D32C2C}door broken down" , p );
- SendClientMessage(playerid, 0xFF0000AA, str);
- }
- }
- return 1;
- }
- /*YCMD:rentroom( playerid , params[] , help )
- {
- #pragma unused params
- #pragma unused help
- rentProperty( playerid );
- return 1;
- }*/
- YCMD:sp( playerid , params[] , help )
- {
- #pragma unused playerid
- #pragma unused help
- saveProperty( strval(params) );
- return 1;
- }
- YCMD:buyproperty( playerid , params[] , help )
- {
- #pragma unused params
- #pragma unused help
- buyProperty( playerid );
- return 1;
- }
- YCMD:sellproperty( playerid , params[] , help )
- {
- #pragma unused params
- #pragma unused help
- sellProperty( playerid );
- return 1;
- }
- YCMD:jetpack( playerid , params[] , help )
- {
- #pragma unused params
- #pragma unused help
- SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USEJETPACK);
- GameTextForPlayer( playerid , "~w~JetPack ~r~YO", 3, 3 );
- return 1;
- }
- YCMD:v( playerid , params[] , help )
- {
- #pragma unused playerid
- #pragma unused help
- new id, c1, c2;
- if( sscanf( params , "ddd" , id , c1 , c2 ) )
- {
- SendClientMessage(playerid , -1 , "{AAFFAA}/v [model] [color1] [color2]" );
- }
- new Float:x,Float:y,Float:z,Float:a;
- GetPlayerFacingAngle(playerid , a);
- GetPlayerPos( playerid , x , y, z);
- CreateVehicle( id , x, y, z , a, c1, c2, 999*999*999);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement