Advertisement
luisgustavomiki

miki!Houses - 0.1

May 3rd, 2011
1,168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 38.07 KB | None | 0 0
  1. #include <a_samp>
  2. #include <mysql>
  3. #include <streamer>
  4. #include <float>
  5. #include <YSI\y_commands>
  6. #include <sscanf2>
  7. ///////////////////////////
  8. #define MAX_PROPERTIES 100
  9. #define MAX_CINTS 50
  10. #define MAX_TENANTS 50
  11. ///////////////////////////
  12. #define COLOR_3D            0x00CC00FF
  13. #define COLOR_3D_FREE       0xB6FC69FF
  14. ///////////////////////////
  15. #define PROP_TYPE_HOUSE             0
  16. #define PROP_TYPE_BUSINESS          1
  17. #define PROP_TYPE_APARTMENT_COMPLEX 2
  18. #define PROP_TYPE_FACTION_HOUSE     3
  19. #define PROP_TYPE_FACTION_BUSINESS  4
  20. #define PROP_TYPE_APARTMENT         5
  21. //////////////////////////
  22. #define MYSQL_HOST  "localhost"
  23. #define MYSQL_USER  "samp"
  24. #define MYSQL_PASS  "samp"
  25. #define MYSQL_DB    "sa-mp"
  26. //////////////////////////
  27. #define MSG_DOOR_HOUSE                  "You're at {F0E12F}%s's {FFFFFF}house door!"
  28. #define MSG_DOOR_BUSINESS               "You're at {F0E12F}%s's door!"
  29. #define MSG_DOOR_APARTMENT_COMPLEX      "You're at {F0E12F}%s's {FFFFFF}Apartment Complex!"
  30. #define MSG_DOOR_FACTION_HOUSE          "You're at {F0E12F}%s's {FFFFFF}house door! ((%s))"
  31. #define MSG_DOOR_FACTION_BUSINESS       "You're at {F0E12F}%s's door!"
  32. #define MSG_DOOR_APARTMENT              "You're at {F0E12F}%s's apartment door!"
  33. #define MSG_DOOR_HOUSE_SOLD             "This {F0E12F}house {FFFFFF}is for sale!"
  34. #define MSG_DOOR_BUSINESS_SOLD          "This {F0E12F}business {FFFFFF}is for sale!"
  35. #define MSG_DOOR_APARTMENT_COMPLEX_SOLD "This {F0E12F}apartment complex {FFFFFF}is for sale!"
  36. #define MSG_DOOR_FACTION_HOUSE_SOLD     "This {F0E12F}house {FFFFFF}is for sale! ((Faction))"
  37. #define MSG_DOOR_FACTION_BUSINESS_SOLD  "This {F0E12F}business {FFFFFF}is for sale! ((Faction))"
  38. #define MSG_DOOR_APARTMENT_SOLD         "This {F0E12F}apartment {FFFFFF}is for sale!"
  39. /////////////////////////
  40. #define DIALOG_PP 25000
  41. /////////////////////////
  42. #define quickMessage(%0); SendClientMessage(playerid,-1,%0);
  43. /////////////////////////
  44. forward dbUpdate();
  45. /////////////////////////// fini ///////////////////////////////////////////
  46.     #define MaxLines    (999)
  47.     #define MaxKeys     (064)
  48.  
  49.     #define Fini_GetBool(%0)    (bool:strval(Fini_GetStr(%0)))
  50.     #define Fini_GetValue(%0)   (strval(Fini_GetStr(%0)))
  51.     #define Fini_Exists(%0)     (fexist(%0))
  52.     #define Fini_GetFloat(%0)   floatstr(Fini_GetStr(%0))
  53.     #define Fini_Remove(%0)     (fremove(%0))
  54.  
  55.     new
  56.     sCacheKeys[MaxLines][MaxKeys],
  57.     sCacheValue[MaxLines][MaxKeys],
  58.     iLoop           = 0x0,
  59.     iFind           = 0x0,
  60.     iKeySet         = 0x0,
  61.     File:iFile      = File:0,
  62.     sTemp[MaxKeys]  = " ";
  63.  
  64.     stock Fini_GetStr(sKey[])
  65.     {
  66.         iLoop = 0x0;
  67.         while((sCacheKeys[iLoop][0x0]) && (iLoop < MaxLines)) {
  68.             if(!strcmp(sCacheKeys[iLoop],sKey,false))
  69.                 return sCacheValue[iLoop];
  70.             ++iLoop;
  71.         }
  72.         return sCacheKeys[0];
  73.     }
  74.     stock   Fini_Create(sFile[])
  75.     {
  76.         if(Fini_Exists(sFile)) return false;
  77.         iFile = fopen(sFile,io_write);
  78.         return fclose(iFile);
  79.     }
  80.     stock Fini_OpenFile(sFile[])
  81.     {
  82.         iFile = fopen(sFile,io_read),
  83.             iFind   = 0x0;
  84.         iLoop = 0x0;
  85.  
  86.         while(fread(iFile,sTemp)) {
  87.             sTemp[strlen(sTemp) - 2] = EOS;
  88.             iFind   = strfind(sTemp,"=");
  89.             format(sCacheValue[iLoop],MaxKeys,sTemp[iFind + 1]);
  90.             sTemp[iFind] = EOS;
  91.             format(sCacheKeys[iLoop],MaxKeys,sTemp);
  92.             ++iLoop;
  93.         }
  94.         return fclose(iFile);
  95.     }
  96.     stock Fini_SaveFile(sFile[])
  97.     {
  98.         iFile = fopen(sFile,io_write),
  99.             sTemp[0] = EOS;
  100.  
  101.         iLoop = 0x0;
  102.         while((sCacheKeys[iLoop][0x0]) && (iLoop < MaxLines)) {
  103.             format(sTemp,MaxKeys,"%s=%s\r\n",sCacheKeys[iLoop],sCacheValue[iLoop]);
  104.             fwrite(iFile,sTemp);
  105.             ++iLoop;
  106.         }
  107.         return fclose(iFile);
  108.     }
  109.     stock Fini_CloseFile()
  110.     {
  111.         sCacheKeys[0][0]    =   EOS;
  112.         sCacheValue[0][0]   =   EOS;
  113.         iLoop               =   0x0;
  114.         iFind               =   0x0;
  115.         iKeySet             =   0x0;
  116.         sTemp[0]            =   EOS;
  117.         return true;
  118.     }
  119.     stock Fini_IsSet(sTag[])
  120.     {
  121.         iLoop = 0x0;
  122.         while((sCacheKeys[iLoop][0x0]) && (iLoop < MaxLines)) {
  123.             if(!strcmp(sCacheKeys[iLoop],sTag,false)) {
  124.                 return true;
  125.             }
  126.             iLoop++;
  127.         }
  128.         return false;
  129.     }
  130.     stock Fini_SetStr(sKey[],sValue[])
  131.     {
  132.         iLoop = 0x0;
  133.         while((sCacheKeys[iLoop][0x0]) && (iLoop < MaxLines)) {
  134.             if(!strcmp(sCacheKeys[iLoop],sKey,false)) {
  135.                 sCacheValue[iLoop][0] = EOS;
  136.                 strcat(sCacheValue[iLoop],sValue);
  137.                 iKeySet = 1;
  138.             }
  139.             ++iLoop;
  140.         }
  141.         if(!iKeySet) {
  142.             while(sCacheKeys[iLoop][0]) iLoop++;
  143.             strcat(sCacheValue[iLoop],sValue);
  144.             strcat(sCacheKeys[iLoop],sKey);
  145.         }
  146.         return EOS;
  147.     }
  148.     stock Fini_SetFloat(sTag[],Float:iVal)
  149.     {
  150.         format(sTemp,MaxKeys,"%f",iVal);
  151.         return Fini_SetStr(sTag,sTemp);
  152.     }
  153.     stock Fini_SetVal(sTag[],iVal)
  154.     {
  155.         format(sTemp,MaxKeys,"%d",iVal);
  156.         return Fini_SetStr(sTag,sTemp);
  157.     }
  158.     stock Fini_SetBool(sTag[],bool:iVal)
  159.     {
  160.         format(sTemp,MaxKeys,"%d",iVal);
  161.         return Fini_SetStr(sTag,sTemp);
  162.     }
  163.  
  164. //////////////////////////////////////////// Ignore: OFF ////////////////////////////////////////////////
  165.  
  166.  
  167. enum PROPERTY_INFO
  168. {
  169.     Float:E_X,
  170.     Float:E_Y,
  171.     Float:E_Z,
  172.     E_INT,
  173.     E_VW,
  174.     Float:I_X,
  175.     Float:I_Y,
  176.     Float:I_Z,
  177.     I_INT,
  178.     TYPE,
  179.     LEVEL,
  180.     CASHBOX,
  181.     NAME[MAX_PLAYER_NAME],
  182.     OWNER[MAX_PLAYER_NAME],
  183.     CO_OWNER[MAX_PLAYER_NAME],
  184.     SOLD,
  185.     LOCK,
  186.     ALARM,
  187.     PRICE,
  188.     USED_SLOT
  189. }
  190. enum WEAPON_SLOTS
  191. {
  192.     _a[2],
  193.     _b[2],
  194.     _c[2],
  195.     _d[2],
  196.     _e[2],
  197.     _f[2],
  198.     _g[2],
  199.     _h[2],
  200.     _i[2],
  201.     _j[2]
  202. }
  203. enum PROPERTY_STATS
  204. {
  205.     DOOR,
  206.     ALARM,
  207.     WEAPONS[WEAPON_SLOTS],
  208.     ADMIN_LOCKED,
  209.     ENTRANCE_FEE
  210.    
  211. }
  212.  
  213. enum INTERIOR_INFO
  214. {
  215.     Float:X,
  216.     Float:Y,
  217.     Float:Z,
  218.     INT
  219. }
  220.  
  221. new
  222.     propertyTenants         [MAX_PROPERTIES]    [MAX_TENANTS]       [MAX_PLAYER_NAME],
  223.     propertyInfo            [MAX_PROPERTIES]    [PROPERTY_INFO],
  224.     interiorInfo            [MAX_CINTS]         [INTERIOR_INFO],
  225.     propertyStats           [MAX_PROPERTIES]    [PROPERTY_STATS],
  226.     propertyCP              [MAX_PROPERTIES],
  227.     Text3D:property3D       [MAX_PROPERTIES],
  228.     loadedProperties;
  229.  
  230. main() {}
  231.  
  232. public OnGameModeInit()
  233. {
  234.     DisableInteriorEnterExits();
  235.     mysql_init();
  236.     mysql_connect(MYSQL_HOST,MYSQL_USER,MYSQL_PASS,MYSQL_DB);
  237.     loadProperties();
  238.     loadInteriors();
  239.     SetTimer("dbUpdate", 60*5000, true );
  240.  
  241.     return 1;
  242. }
  243. public dbUpdate()
  244. {
  245.     new i = 1;
  246.     while( i < loadedProperties )
  247.     {
  248.         saveProperty(i);
  249.         printf("|--- propertyInfo[%d] was successfuly saved to the database", i );
  250.         i++;
  251.        
  252.     }
  253. }
  254.  
  255. stock loadProperties()
  256. {
  257.     new query[256];
  258.     new count = 0;
  259.     for(new i = 1; i < MAX_PROPERTIES; i++)
  260.     {
  261.         format(query, sizeof(query),"SELECT * FROM propertyinfo WHERE id=%d",i);
  262.         mysql_query(query);
  263.         mysql_store_result();
  264.         if(mysql_num_rows())
  265.         if(mysql_fetch_row(query,"|")) // Splits the row
  266.         {
  267.             printf("\n|------ Loading Property ID: %d" , i );
  268.             new field[22][MAX_PLAYER_NAME];
  269.             explode(query, field, "|");
  270.             mysql_free_result();
  271.             count++;
  272.             propertyInfo [i] [E_X]          =   floatstr( field[  1 ] );
  273.             propertyInfo [i] [E_Y]          =   floatstr( field[  2 ] );
  274.             propertyInfo [i] [E_Z]          =   floatstr( field[  3 ] );
  275.             propertyInfo [i] [E_INT]        =   strval  ( field[  4 ] );
  276.             propertyInfo [i] [E_VW]         =   strval  ( field[  5 ] );
  277.             printf("|--- Exterior Info| X: %f | Y: %f | Z: %f" , propertyInfo [i] [E_X],propertyInfo [i] [E_Y],propertyInfo [i] [E_Z] );
  278.             printf("|--- INT: %d | VW: %d" , propertyInfo [i] [E_INT],propertyInfo [i] [E_VW] );
  279.             propertyInfo [i] [I_X]          =   floatstr( field[  6 ] );
  280.             propertyInfo [i] [I_Y]          =   floatstr( field[  7 ] );
  281.             propertyInfo [i] [I_Z]          =   floatstr( field[  8 ] );
  282.             propertyInfo [i] [I_INT]        =   strval  ( field[  9 ] );
  283.            
  284.             printf("|--- Interior Info| X: %f | Y: %f | Z: %f" , propertyInfo [i] [I_X],propertyInfo [i] [I_Y],propertyInfo [i] [I_Z] );
  285.             printf("|--- INT: %d" , propertyInfo [i] [I_INT]);
  286.             propertyInfo [i] [TYPE]         =   strval  ( field[ 10 ] );
  287.             propertyInfo [i] [LEVEL]        =   strval  ( field[ 11 ] );
  288.             propertyInfo [i] [CASHBOX]      =   strval  ( field[ 12 ] );
  289.             printf("|--- Property TYPE: %d | Level: %d | Cashbox: %d" , propertyInfo [i] [TYPE] , propertyInfo [i] [LEVEL] , propertyInfo [i] [CASHBOX] );
  290.             propertyInfo [i] [NAME]         =   field[ 13 ];
  291.             propertyInfo [i] [OWNER]        =   field[ 14 ];
  292.             propertyInfo [i] [CO_OWNER]     =   field[ 15 ];
  293.             printf("|--- Name: %s | Owner: %s | Co-Owner: %s" , propertyInfo [i] [NAME] , propertyInfo [i] [OWNER] , propertyInfo [i] [CO_OWNER] );
  294.             propertyInfo [i] [SOLD]         =   strval  ( field[ 16 ] );
  295.             propertyInfo [i] [LOCK]         =   strval  ( field[ 17 ] );
  296.             propertyInfo [i] [ALARM]        =   strval  ( field[ 18 ] );
  297.             propertyInfo [i] [PRICE]        =   strval  ( field[ 19 ] );
  298.             printf("|--- Sold: %b | Lock Level: %d | Alarm Level: %d | Price: %d" , propertyInfo [i] [SOLD] , propertyInfo [i] [LOCK] , propertyInfo [i] [ALARM], propertyInfo [i] [PRICE]);
  299.             propertyInfo [i] [USED_SLOT]    =   true;
  300.             ///////////////////////////////////////////////////////////
  301.             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);
  302.             printf("|--- PROPERTYID: %d | Loaded propertyCP: ID: %d" , i , propertyCP[i] );
  303.             ///////////////////////////////////////////////////////////
  304.             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);
  305.             printf("|--- PROPERTYID: %d | Loaded property3D: ID: %d" , i , property3D[i] );
  306.             ///////////////////////////////////////////////////////////
  307.            
  308.             new temp[45];
  309.             format( temp , 45 , "propertySystem/stats/prop_%d.ini" , i );
  310.            
  311.             if(!fexist(temp))
  312.             {
  313.                     Fini_Create(temp);
  314.                     Fini_OpenFile(temp);
  315.                     Fini_SetVal( "DOOR"  , 0 );
  316.                     Fini_SetVal( "ALARM" , 0 );
  317.                     Fini_SetVal( "ADMIN_LOCKED" , 0 );
  318.                     Fini_SetVal( "ENTRANCE_FEE" , 0 );
  319.                     new l;
  320.                     while( l <= 10 )
  321.                     {
  322.                         new str[15];
  323.                         format( str , 15 , "WEAPON%d_ID" , l );
  324.                         Fini_SetVal( str , 0 );
  325.                         format( str , 15 , "WEAPON%d_AMMO" , l );
  326.                         Fini_SetVal( str , 0 );
  327.                         l++;
  328.                     }
  329.                     Fini_SaveFile(temp);
  330.                     Fini_CloseFile();
  331.                    
  332.             }
  333.             else
  334.             {
  335.                 Fini_OpenFile(temp);
  336.                 propertyStats[i][DOOR]  = Fini_GetValue("DOOR");
  337.                 propertyStats[i][ALARM] = Fini_GetValue("ALARM");
  338.                 propertyStats[i][ADMIN_LOCKED] = Fini_GetValue("ADMIN_LOCKED");
  339.                 propertyStats[i][ENTRANCE_FEE] = Fini_GetValue("ENTRANCE_FEE");
  340.                
  341.                 propertyStats[i][WEAPONS][_a][0] = Fini_GetValue("WEAPON0_ID");
  342.                 propertyStats[i][WEAPONS][_a][1] = Fini_GetValue("WEAPON0_AMMO");
  343.                 propertyStats[i][WEAPONS][_b][0] = Fini_GetValue("WEAPON1_ID");
  344.                 propertyStats[i][WEAPONS][_b][1] = Fini_GetValue("WEAPON1_AMMO");
  345.                 propertyStats[i][WEAPONS][_c][0] = Fini_GetValue("WEAPON2_ID");
  346.                 propertyStats[i][WEAPONS][_c][1] = Fini_GetValue("WEAPON2_AMMO");
  347.                 propertyStats[i][WEAPONS][_d][0] = Fini_GetValue("WEAPON3_ID");
  348.                 propertyStats[i][WEAPONS][_d][1] = Fini_GetValue("WEAPON3_AMMO");
  349.                 propertyStats[i][WEAPONS][_e][0] = Fini_GetValue("WEAPON4_ID");
  350.                 propertyStats[i][WEAPONS][_e][1] = Fini_GetValue("WEAPON4_AMMO");
  351.                 propertyStats[i][WEAPONS][_f][0] = Fini_GetValue("WEAPON5_ID");
  352.                 propertyStats[i][WEAPONS][_f][1] = Fini_GetValue("WEAPON5_AMMO");
  353.                 propertyStats[i][WEAPONS][_g][0] = Fini_GetValue("WEAPON6_ID");
  354.                 propertyStats[i][WEAPONS][_g][1] = Fini_GetValue("WEAPON6_AMMO");
  355.                 propertyStats[i][WEAPONS][_h][0] = Fini_GetValue("WEAPON7_ID");
  356.                 propertyStats[i][WEAPONS][_h][1] = Fini_GetValue("WEAPON7_AMMO");
  357.                 propertyStats[i][WEAPONS][_i][0] = Fini_GetValue("WEAPON8_ID");
  358.                 propertyStats[i][WEAPONS][_i][1] = Fini_GetValue("WEAPON8_AMMO");
  359.                 propertyStats[i][WEAPONS][_j][0] = Fini_GetValue("WEAPON9_ID");
  360.                 propertyStats[i][WEAPONS][_j][1] = Fini_GetValue("WEAPON9_AMMO");
  361.                
  362.  
  363.                 Fini_SaveFile(temp);
  364.  
  365.                 Fini_CloseFile();
  366.                
  367.             }
  368.             format( temp , 45 , "propertySystem/stats/prop_%d_tenants.ini" , i );
  369.  
  370.             if(!fexist(temp))
  371.             {
  372.                 Fini_Create(temp);
  373.             }
  374.             else
  375.             {
  376.                 Fini_OpenFile(temp);
  377.  
  378.                 new l;
  379.  
  380.                 while( l < MAX_TENANTS )
  381.                 {
  382.                     new name[20], n[5];
  383.                     format( n , sizeof(n) , "%d" , l );
  384.                     format( name , sizeof(name) , "%s" , Fini_GetStr(n) );
  385.                     propertyTenants[i][l] = name;
  386.                     l++;
  387.                 }
  388.                 Fini_CloseFile();
  389.  
  390.             }
  391.             printf("|------ Property ID: %d Loaded" , i );
  392.             printf("|------ and the Labels were updated!\n" , i );
  393.             updateProperty( i );
  394.         }
  395.     }
  396.     printf("################################\n\t%d Properties were loaded\n",count);
  397.     loadedProperties = count + 1;
  398. }
  399.  
  400. stock loadInteriors()
  401. {
  402.     new query[256];
  403.     new count = 0;
  404.     for(new i; i < MAX_CINTS; i++)
  405.     {
  406.         format(query, sizeof(query),"SELECT * FROM interiorinfo WHERE id=%d",i);
  407.         mysql_query(query);
  408.         mysql_store_result();
  409.         if(mysql_num_rows())
  410.         if(mysql_fetch_row(query,"|")) // Splits the row
  411.         {
  412.             printf("\n|------ Loading Inteior ID: %d" , i );
  413.             new field[5][25];
  414.             explode(query, field, "|");
  415.             mysql_free_result();
  416.             count++;
  417.             interiorInfo[i][X]      = floatstr( field[1] );
  418.             interiorInfo[i][Y]      = floatstr( field[2] );
  419.             interiorInfo[i][Z]      = floatstr( field[3] );
  420.             interiorInfo[i][INT]    = strval  ( field[4] );
  421.             printf("|--- Interior Info: X: %f | Y: %f | Z: %f | INT: %d" , interiorInfo[i][X] , interiorInfo[i][Y] , interiorInfo[i][Z] , interiorInfo[i][INT] );
  422.             printf("\n|------ Interior ID %d was successfuly loaded!\n\n" , i );
  423.         }
  424.     }
  425.     printf("###############################################\n\t%d Custom Interiors were loaded\n",count);
  426.    
  427. }
  428.  
  429. stock updateProperty( propertyid )
  430. {
  431.     switch( propertyInfo[propertyid][TYPE] )
  432.     {
  433.         case PROP_TYPE_HOUSE:
  434.         {
  435.             if( propertyInfo[propertyid][SOLD] )
  436.             {
  437.                 UpdateDynamic3DTextLabelText(property3D[propertyid] , 0xE1D92DFF , "House Door");
  438.             }
  439.             else
  440.             {
  441.                 new str[200];
  442.                 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] );
  443.                 UpdateDynamic3DTextLabelText(property3D[propertyid] , 0x258B63FF , str);
  444.             }
  445.         }
  446.         case PROP_TYPE_BUSINESS:
  447.         {
  448.             if( propertyInfo[propertyid][SOLD] )
  449.             {
  450.                 UpdateDynamic3DTextLabelText(property3D[propertyid] , 0xE1D92DFF , propertyInfo [propertyid] [NAME]);
  451.             }
  452.             else
  453.             {
  454.                 new str[200];
  455.                 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] );
  456.                 UpdateDynamic3DTextLabelText(property3D[propertyid] , 0x258B63FF ,str);
  457.             }
  458.         }
  459.         case PROP_TYPE_APARTMENT_COMPLEX:
  460.         {
  461.             if( propertyInfo[propertyid][SOLD] )
  462.             {
  463.                 UpdateDynamic3DTextLabelText(property3D[propertyid] , 0xE1D92DFF , "Apartment Complex");
  464.             }
  465.             else
  466.             {
  467.                 new str[200];
  468.                 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] );
  469.                 UpdateDynamic3DTextLabelText(property3D[propertyid] , 0x258B63FF , str);
  470.             }
  471.         }
  472.         case PROP_TYPE_FACTION_HOUSE:
  473.         {
  474.             if( propertyInfo[propertyid][SOLD] )
  475.             {
  476.                 UpdateDynamic3DTextLabelText(property3D[propertyid] , 0xE1D92DFF , "House Door");
  477.             }
  478.             else
  479.             {
  480.                 new str[200];
  481.                 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] );
  482.                 UpdateDynamic3DTextLabelText(property3D[propertyid] , 0x258B63FF , str);
  483.             }
  484.         }
  485.         case PROP_TYPE_FACTION_BUSINESS:
  486.         {
  487.             if( propertyInfo[propertyid][SOLD] )
  488.             {
  489.                 UpdateDynamic3DTextLabelText(property3D[propertyid] , 0xE1D92DFF , propertyInfo [propertyid] [NAME]);
  490.             }
  491.             else
  492.             {
  493.                 new str[200];
  494.                 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] );
  495.                 UpdateDynamic3DTextLabelText(property3D[propertyid] , 0x258B63FF , str);
  496.             }
  497.         }
  498.         case PROP_TYPE_APARTMENT:
  499.         {
  500.             if( propertyInfo[propertyid][SOLD] )
  501.             {
  502.                 UpdateDynamic3DTextLabelText(property3D[propertyid] , 0xE1D92DFF , "Apartment Door");
  503.             }
  504.             else
  505.             {
  506.                 new str[200];
  507.                 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] );
  508.                 UpdateDynamic3DTextLabelText(property3D[propertyid] , 0x258B63FF , str);
  509.             }
  510.         }
  511.     }
  512. }
  513.  
  514.  
  515. stock createPropriety( Float:x , Float:y , Float:z , interiorid , vw,  type , level , cintid , lock , alarm , price)
  516. {
  517.     new str[500], field[6][32];
  518.     format( str , sizeof(str) , "SELECT * FROM interiorinfo WHERE ID=%d", cintid );
  519.     mysql_query(str);
  520.     mysql_store_result();
  521.     if(mysql_num_rows()) {
  522.       if(mysql_fetch_row(str,"|")) {
  523.             explode(str, field, "|");
  524.       }
  525.     }
  526.     mysql_free_result();
  527.     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`) \
  528.      VALUES ('NULL', '%f', '%f', '%f', '%d', '%d', '%f', '%f', '%f', '%d', '0', '%d', '%d', '%s', '%s', '%s', '0', '%d', '%d', '%d')",
  529.     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 );
  530.     //print(str);
  531.     mysql_query(str);
  532. }
  533.  
  534. stock saveProperty( propertyid )
  535. {
  536.     if( propertyInfo[propertyid][USED_SLOT] == 1 )
  537.     {
  538.         new str[512];
  539.         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',\
  540.         `NAME`='%s', `OWNER`='%s', `CO_OWNER`='%s', `SOLD`='%d', `LOCK`='%d', \
  541.         `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],
  542.         propertyInfo[propertyid][I_X],propertyInfo[propertyid][I_Y],propertyInfo[propertyid][I_Z],
  543.         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],
  544.         propertyInfo[propertyid][LOCK],propertyInfo[propertyid][ALARM],propertyInfo[propertyid][PRICE], propertyid );
  545.         mysql_query(str);
  546.         //print(str);
  547.         new temp[45];
  548.         format( temp , 45 , "propertySystem/stats/prop_%d.ini" , propertyid );
  549.         if(!fexist(temp))
  550.         {
  551.             Fini_OpenFile(temp);
  552.             Fini_SetVal("DOOR",propertyStats[propertyid][DOOR]);
  553.             Fini_SetVal("ALARM",propertyStats[propertyid][ALARM]);
  554.             Fini_SetVal("ADMIN_LOCKED",propertyStats[propertyid][ADMIN_LOCKED]);
  555.             Fini_SetVal("ENTRANCE_FEE",propertyStats[propertyid][ENTRANCE_FEE]);
  556.             Fini_SaveFile(temp);
  557.             Fini_CloseFile();
  558.         }
  559.         format( temp , 45 , "propertySystem/stats/prop_%d_tenants.ini" , propertyid );
  560.         if(!fexist(temp))
  561.         {
  562.             new i;
  563.             while( i < MAX_TENANTS )
  564.             {
  565.                 Fini_OpenFile(temp);
  566.                 new name[20], n[5];
  567.                 format( n , sizeof(n) , "%d" , i );
  568.                 format( name , sizeof(name) , "%s" , propertyTenants[propertyid][i] );
  569.                 Fini_SetStr(n,name);
  570.                 i++;
  571.             }
  572.             Fini_SaveFile(temp);
  573.             Fini_CloseFile();
  574.         }
  575.        
  576.         return 1;
  577.     }
  578.     else return 0;
  579. }
  580.  
  581. stock savePropertyStats( propertyid )
  582. {
  583.     if( propertyInfo[propertyid][USED_SLOT] == 1 )
  584.     {
  585.         new temp[45];
  586.         format( temp , 45 , "propertySystem/stats/prop_%d.ini" , propertyid );
  587.         if(!fexist(temp))
  588.         {
  589.             Fini_OpenFile(temp);
  590.             Fini_SetVal("DOOR",propertyStats[propertyid][DOOR]);
  591.             Fini_SetVal("ALARM",propertyStats[propertyid][ALARM]);
  592.             Fini_SetVal("ADMIN_LOCKED",propertyStats[propertyid][ADMIN_LOCKED]);
  593.             Fini_SetVal("ENTRANCE_FEE",propertyStats[propertyid][ENTRANCE_FEE]);
  594.             Fini_SaveFile(temp);
  595.             Fini_CloseFile();
  596.         }
  597.         format( temp , 45 , "propertySystem/stats/prop_%d_tenants.ini" , propertyid );
  598.         if(!fexist(temp))
  599.         {
  600.             new i;
  601.             while( i < MAX_TENANTS )
  602.             {
  603.                 Fini_OpenFile(temp);
  604.                 new name[20], n[5];
  605.                 format( n , sizeof(n) , "%d" , i );
  606.                 format( name , sizeof(name) , "%s" , propertyTenants[propertyid][i] );
  607.                 Fini_SetStr(n,name);
  608.                 i++;
  609.             }
  610.             Fini_SaveFile(temp);
  611.             Fini_CloseFile();
  612.         }
  613.  
  614.         return 1;
  615.     }
  616.     else return 0;
  617. }
  618.  
  619. stock enterProperty( playerid )
  620. {
  621.     if( GetPVarInt( playerid , "StandingAt" ) != 0 )
  622.     {
  623.         new p = GetPVarInt( playerid , "StandingAt" );
  624.        
  625.         if( propertyStats[p][DOOR] == 0 )
  626.         {
  627.             SetPVarInt( playerid , "Inside" , p );
  628.             SetPlayerInterior( playerid , propertyInfo[p][I_INT] );
  629.             SetPlayerPos( playerid , propertyInfo[p][I_X], propertyInfo[p][I_Y], propertyInfo[p][I_Z] );
  630.             SetPlayerVirtualWorld( playerid , p );
  631.         }
  632.         if( propertyStats[p][DOOR] == 1 )
  633.         {
  634.             GameTextForPlayer( playerid , "~w~The door seems to be ~r~locked" , 3000 , 3 );
  635.             PlayerPlaySound(playerid, 1135, 0, 0, 0 );
  636.         }
  637.         else
  638.         {
  639.             SetPVarInt( playerid , "Inside" , p );
  640.             SetPlayerInterior( playerid , propertyInfo[p][I_INT] );
  641.             SetPlayerPos( playerid , propertyInfo[p][I_X], propertyInfo[p][I_Y], propertyInfo[p][I_Z] );
  642.             SetPlayerVirtualWorld( playerid , p );
  643.         }
  644.  
  645.         return 1;
  646.     }
  647.     else return 0;
  648.    
  649. }
  650.  
  651. stock exitProperty( playerid )
  652. {
  653.     if( GetPVarInt( playerid , "Inside" ) != 0 )
  654.     {
  655.         new p = GetPVarInt( playerid , "Inside" );
  656.         if( propertyStats[p][DOOR] == 0 )
  657.         {
  658.             SetPVarInt( playerid , "Inside" , 0 );
  659.             SetPlayerInterior( playerid , propertyInfo[p][E_INT] );
  660.             SetPlayerPos( playerid , propertyInfo[p][E_X], propertyInfo[p][E_Y], propertyInfo[p][E_Z] );
  661.             SetPlayerVirtualWorld( playerid , propertyInfo[p][E_VW] );
  662.         }
  663.         if( propertyStats[p][DOOR] == 1 )
  664.         {
  665.             GameTextForPlayer( playerid , "~w~This door seems to be ~r~locked" , 3000 , 3 );
  666.             PlayerPlaySound(playerid, 1135, 0, 0, 0 );
  667.         }
  668.         else
  669.         {
  670.             SetPVarInt( playerid , "Inside" , 0 );
  671.             SetPlayerInterior( playerid , propertyInfo[p][E_INT] );
  672.             SetPlayerPos( playerid , propertyInfo[p][E_X], propertyInfo[p][E_Y], propertyInfo[p][E_Z] );
  673.             SetPlayerVirtualWorld( playerid , propertyInfo[p][E_VW] );
  674.         }
  675.         return 1;
  676.  
  677.     }
  678.     else return 0;
  679. }
  680.  
  681. stock buyProperty( playerid )
  682. {
  683.     if( GetPVarInt( playerid , "StandingAt" ) != 0 )
  684.     {
  685.         new p = GetPVarInt( playerid , "StandingAt" );
  686.  
  687.         if( propertyInfo[p][SOLD] == 0 )
  688.         {
  689.             if( GetPlayerMoney(playerid) >= propertyInfo[p][PRICE] )
  690.             {
  691.                 format( propertyInfo[p][OWNER] , MAX_PLAYER_NAME , "%s" , pName( playerid , false ) );
  692.                 propertyInfo[p][SOLD] = 1;
  693.                 SendClientMessage( playerid , -1 , "You've just bought this property!" );
  694.                 SendClientMessage( playerid , -1 , "    (( Type /propertyhelp to get started! ))" );
  695.                 saveProperty( p );
  696.                 updateProperty( p );
  697.             }
  698.             else
  699.             {
  700.                 SendClientMessage( playerid , -1 , "You don't have that money!" );
  701.             }
  702.         }
  703.     }
  704. }
  705.  
  706. stock sellProperty( playerid )
  707. {
  708.     if( GetPVarInt( playerid , "StandingAt" ) != 0 )
  709.     {
  710.         new p,
  711.             n[MAX_PLAYER_NAME],
  712.             o[MAX_PLAYER_NAME];
  713.         p = GetPVarInt( playerid , "StandingAt" );
  714.         GetPlayerName(playerid , n , MAX_PLAYER_NAME );
  715.         format( o , sizeof(o) , "%s" , propertyInfo[p][OWNER] );
  716.         if( strmatch( n , o ) )
  717.         {
  718.             if( propertyInfo[p][SOLD] == 1 )
  719.             {
  720.                 new price = propertyInfo[p][PRICE],
  721.                     money,
  722.                     str[80];
  723.                 money = ((price/10)*8);
  724.                 propertyInfo[p][SOLD] = 0;
  725.                 format( propertyInfo[p][OWNER] , MAX_PLAYER_NAME , "None" );
  726.                 format( propertyInfo[p][CO_OWNER] , MAX_PLAYER_NAME , "None" );
  727.                 format( str , sizeof(str) , "You have just sold your property and got $%d!" , money );
  728.                 SendClientMessage( playerid , -1 , str );
  729.                 saveProperty( p );
  730.                 updateProperty( p );
  731.             }
  732.             else
  733.             {
  734.                  SendClientMessage( playerid , -1 , "You can't sell this property!" );
  735.             }
  736.         }
  737.         else
  738.         {
  739.             SendClientMessage( playerid , -1 , "You don't own this property!" );
  740.         }
  741.     }
  742. }
  743.  
  744. /*stock rentProperty( playerid )
  745. {
  746.    
  747. }*/
  748.  
  749. stock lockProperty( playerid )
  750. {
  751.     new stand,
  752.         inside,
  753.         p,
  754.         owner[MAX_PLAYER_NAME];
  755.  
  756.     stand = GetPVarInt( playerid , "StandingAt" );
  757.     inside = GetPVarInt( playerid , "Inside" );
  758.  
  759.     /* debug
  760.  
  761.     new _debug[50];
  762.     format( _debug , sizeof(_debug) , "[STANDINGPROPERTY: %d] [INSIDEPROPERTY: %d]" , stand , inside );
  763.     SendClientMessage( playerid , -1 , _debug );
  764.  
  765.     */
  766.  
  767.  
  768.     if( inside == 0 && stand == 0 )
  769.     {
  770.         GameTextForPlayer( playerid , "~w~There are no ~b~locks ~w~around" , 2000 , 3 );
  771.     }
  772.     else
  773.     {
  774.         if( inside > 0 ) p = inside;
  775.         else p = stand;
  776.  
  777.         /* debug
  778.         format( _debug , sizeof(_debug) , "You're in propertyid [%d]" , p );
  779.         SendClientMessage( playerid , -1 , _debug );
  780.         */
  781.  
  782.         format( owner , sizeof(owner) , "%s" , propertyInfo[p][OWNER] );
  783.         if( strmatch( owner , pName( playerid , false ) ) )
  784.         {
  785.             new dstats = propertyStats[p][DOOR];
  786.             /* debug
  787.             format( _debug , sizeof(_debug) , "The door stat is [%d]" , dstats );
  788.             SendClientMessage( playerid , -1 , _debug );
  789.             */
  790.             if( dstats == 0 )
  791.             {
  792.                 propertyStats[p][DOOR] = 1;
  793.                 PlayerPlaySound(playerid, 1145, 0 , 0, 0);
  794.                 GameTextForPlayer( playerid , "~w~door ~r~locked" , 2000 , 3 );
  795.                 savePropertyStats( p );
  796.                 // opened
  797.             }
  798.             if( dstats == 1 )
  799.             {
  800.                 propertyStats[p][DOOR] = 0;
  801.                 PlayerPlaySound(playerid, 1145, 0 , 0, 0);
  802.                 GameTextForPlayer( playerid , "~w~door ~g~unlocked" , 2000 , 3 );
  803.                 savePropertyStats( p );
  804.                 // locked
  805.             }
  806.             if( dstats == 2 )
  807.             {
  808.                 GameTextForPlayer( playerid , "~w~this door was ~r~broken ~w~down" , 2000 , 3 );
  809.                 // Broken Down
  810.             }
  811.         }
  812.         // if( keys )
  813.         else
  814.         {
  815.                 GameTextForPlayer( playerid , "~w~where are the ~b~keys?" , 2000 , 3 );
  816.         }
  817.     }
  818. }
  819.  
  820. stock propertyPanel( playerid )
  821. {
  822.     new p = GetPVarInt( playerid , "Inside" );
  823.     if( p == 0 )
  824.     {
  825.         quickMessage("You aren't at any property!");
  826.     }
  827.     else
  828.     {
  829.         if( isOwner( playerid , p ) )
  830.         {
  831.             ShowPlayerDialog( playerid , DIALOG_PP , DIALOG_STYLE_LIST , "property Panel" , "Set Name\nSet Entrance Price\nCashbox\nSet Co-Owner\nUpgrades\nOwning Operations" , "Select" , "Cancel" );
  832.         }
  833.         else
  834.         {
  835.             quickMessage("You don't own this property!");
  836.         }
  837.     }
  838. }
  839.  
  840. stock isOwner( playerid , p )
  841. {
  842.     new _p[MAX_PLAYER_NAME] , _o[MAX_PLAYER_NAME];
  843.     GetPlayerName( playerid , p , sizeof(p) );
  844.     format( owner , sizeof(owner) , "%s" , propertyInfo[p][OWNER] );
  845.     if( strmatch( _o , _p ) )
  846.     {
  847.         return 1;
  848.     }
  849.     else
  850.     {
  851.         return 0;
  852.     }
  853. }
  854.  
  855.  
  856. stock propertyMessage( playerid , messageid )
  857. {
  858.     switch( messageid )
  859.     {
  860.         case 0: SendClientMessage( playerid , -1 , "You aren't at {9C0A23}any {FFFFFF} entrance." );
  861.         case 1: SendClientMessage( playerid , -1 , "You aren't at {9C0A23}any {FFFFFF} exit." );
  862.         case 2: SendClientMessage( playerid , -1 , "You have {9C0A23}already {FFFFFF}rented this property before." );
  863.         case 3: SendClientMessage( playerid , -1 , "This house has enough tenants!" );
  864.         case 4: SendClientMessage( playerid , -1 , "You've successfully renter this property!" );
  865.     }
  866.     return 0;
  867. }
  868.  
  869. public OnPlayerEnterDynamicCP(playerid, checkpointid)
  870. {
  871.     new i;
  872.     while( i < loadedProperties + 1 )
  873.     {
  874.         if( propertyCP[i] == checkpointid )
  875.         {
  876.             SetPVarInt( playerid , "StandingAt" , i );
  877.             switch( propertyInfo[i][TYPE] )
  878.             {
  879.                 case PROP_TYPE_HOUSE:
  880.                 {
  881.                     if(propertyInfo [i] [SOLD])
  882.                     {
  883.                         new str[100];
  884.                         format( str , 100 , MSG_DOOR_HOUSE, propertyInfo[i][OWNER] );
  885.                         SendClientMessage( playerid , -1 , str );
  886.                     }
  887.                     else
  888.                     {
  889.                         new str[100];
  890.                         format( str , 100 , MSG_DOOR_HOUSE_SOLD, propertyInfo[i][OWNER] );
  891.                         SendClientMessage( playerid , -1 , str );
  892.                     }
  893.                     break;
  894.                 }
  895.                 case PROP_TYPE_BUSINESS:
  896.                 {
  897.                     if(propertyInfo [i] [SOLD])
  898.                     {
  899.                         new str[100];
  900.                         format( str , 100 , MSG_DOOR_HOUSE, propertyInfo[i][OWNER] );
  901.                         SendClientMessage( playerid , -1 , str );
  902.                     }
  903.                     else
  904.                     {
  905.                         new str[100];
  906.                         format( str , 100 , MSG_DOOR_HOUSE_SOLD, propertyInfo[i][OWNER] );
  907.                         SendClientMessage( playerid , -1 , str );
  908.                     }
  909.                     break;
  910.                 }
  911.                 case PROP_TYPE_APARTMENT_COMPLEX:
  912.                 {
  913.                     if(propertyInfo [i] [SOLD])
  914.                     {
  915.                         new str[100];
  916.                         format( str , 100 , MSG_DOOR_APARTMENT_COMPLEX, propertyInfo[i][OWNER] );
  917.                         SendClientMessage( playerid , -1 , str );
  918.                     }
  919.                     else
  920.                     {
  921.                         new str[100];
  922.                         format( str , 100 , MSG_DOOR_APARTMENT_COMPLEX_SOLD, propertyInfo[i][OWNER] );
  923.                         SendClientMessage( playerid , -1 , str );
  924.                     }
  925.                     break;
  926.                 }
  927.                 case PROP_TYPE_FACTION_HOUSE:
  928.                 {
  929.                     if(propertyInfo [i] [SOLD])
  930.                     {
  931.                         new str[100];
  932.                         format( str , 100 , MSG_DOOR_FACTION_HOUSE, propertyInfo[i][OWNER] );
  933.                         SendClientMessage( playerid , -1 , str );
  934.                     }
  935.                     else
  936.                     {
  937.                         new str[100];
  938.                         format( str , 100 , MSG_DOOR_FACTION_HOUSE_SOLD, propertyInfo[i][OWNER] );
  939.                         SendClientMessage( playerid , -1 , str );
  940.                     }
  941.                     break;
  942.                 }
  943.                 case PROP_TYPE_FACTION_BUSINESS:
  944.                 {
  945.                     if(propertyInfo [i] [SOLD])
  946.                     {
  947.                         new str[100];
  948.                         format( str , 100 , MSG_DOOR_FACTION_BUSINESS, propertyInfo[i][OWNER] );
  949.                         SendClientMessage( playerid , -1 , str );
  950.                     }
  951.                     else
  952.                     {
  953.                         new str[100];
  954.                         format( str , 100 , MSG_DOOR_FACTION_BUSINESS_SOLD, propertyInfo[i][OWNER] );
  955.                         SendClientMessage( playerid , -1 , str );
  956.                     }
  957.                     break;
  958.                 }
  959.                 case PROP_TYPE_APARTMENT:
  960.                 {
  961.                     if(propertyInfo [i] [SOLD])
  962.                     {
  963.                         new str[100];
  964.                         format( str , 100 , MSG_DOOR_APARTMENT, propertyInfo[i][OWNER] );
  965.                         SendClientMessage( playerid , -1 , str );
  966.                     }
  967.                     else
  968.                     {
  969.                         new str[100];
  970.                         format( str , 100 , MSG_DOOR_APARTMENT_SOLD, propertyInfo[i][OWNER] );
  971.                         SendClientMessage( playerid , -1 , str );
  972.                     }
  973.                     break;
  974.                 }
  975.             }
  976.            
  977.         }
  978.         else    i++;
  979.     }
  980. }
  981.  
  982. public OnPlayerLeaveDynamicCP(playerid, checkpointid)
  983. {
  984.     if( GetPVarInt( playerid , "StandingAt" ) != 0 )
  985.     {
  986.         SetPVarInt( playerid , "StandingAt" , 0 );
  987.     }
  988. }
  989.  
  990.  
  991.  
  992.  
  993. explode(const sSource[], aExplode[][], const sDelimiter[] = " ", iVertices = sizeof aExplode, iLength = sizeof aExplode[]) // Created by Westie
  994. {
  995.     new
  996.         iNode,
  997.         iPointer,
  998.         iPrevious = -1,
  999.         iDelimiter = strlen(sDelimiter);
  1000.  
  1001.     while(iNode < iVertices)
  1002.     {
  1003.         iPointer = strfind(sSource, sDelimiter, false, iPointer);
  1004.  
  1005.         if(iPointer == -1)
  1006.         {
  1007.             strmid(aExplode[iNode], sSource, iPrevious, strlen(sSource), iLength);
  1008.             break;
  1009.         }
  1010.         else
  1011.         {
  1012.             strmid(aExplode[iNode], sSource, iPrevious, iPointer, iLength);
  1013.         }
  1014.  
  1015.         iPrevious = (iPointer += iDelimiter);
  1016.         ++iNode;
  1017.     }
  1018.     return iPrevious;
  1019. }
  1020.  
  1021. stock strmatch(const String1[], const String2[])
  1022. {
  1023.     if ((strcmp(String1, String2, true, strlen(String2)) == 0) && (strlen(String2) == strlen(String1)))
  1024.     {
  1025.         return true;
  1026.     }
  1027.     else
  1028.     {
  1029.         return false;
  1030.     }
  1031. }
  1032.  
  1033. stock pName( playerid , togglespace )
  1034. {
  1035.     new str[25], index;
  1036.     GetPlayerName( playerid , str , 24 );
  1037.     if( togglespace )
  1038.     {
  1039.         index = strfind( str , "_" , false );
  1040.         str[index] = 32;
  1041.         return str;
  1042.     }
  1043.     else
  1044.     {
  1045.         return str;
  1046.     }
  1047.  
  1048. }
  1049. YCMD:pd(playerid , params[] , help)
  1050. {
  1051.     #pragma unused params
  1052.     #pragma unused help
  1053.     SetPlayerPos( playerid , 1978.76538,-1671.635131,18.545551 );
  1054.     SendClientMessage( playerid , -1 , "Você foi" );
  1055.     return 1;
  1056. }
  1057. YCMD:pegarumabufunfa(playerid , params[] , help)
  1058. {
  1059.     #pragma unused help
  1060.     GivePlayerMoney( playerid , strval(params) );
  1061.     return 1;
  1062. }
  1063. YCMD:createhouse(playerid, params[], help)
  1064. {
  1065.     #pragma unused help
  1066.     new Float:x,
  1067.         Float:y,
  1068.         Float:z,
  1069.         interiorid,
  1070.         vw,
  1071.         type,
  1072.         level,
  1073.         cintid,
  1074.         lock,
  1075.         alarm,
  1076.         price;
  1077.        
  1078.    
  1079.     if (sscanf(params, "dddddd", type , level , cintid , lock , alarm , price))
  1080.     {
  1081.         return SendClientMessage(playerid, 0xFF0000AA, "Usage: /createhouse [type] [level] [cintid] [lock] [alarm] [price]");
  1082.     }
  1083.     GetPlayerPos( playerid , x , y , z );
  1084.     interiorid = GetPlayerInterior( playerid );
  1085.     vw = GetPlayerVirtualWorld(playerid);
  1086.     createPropriety( x , y , z , interiorid , vw,  type , level , cintid , lock , alarm , price);
  1087.     printf("|--- The administrator %s has just created a new house: %f | %f | %f", pName(playerid, true) , x, y, z );
  1088.     return 1;
  1089. }
  1090. YCMD:enter( playerid , params[] , help )
  1091. {
  1092.     #pragma unused params
  1093.     #pragma unused help
  1094.     enterProperty(playerid);
  1095.     return 1;
  1096. }
  1097. YCMD:exit( playerid , params[] , help )
  1098. {
  1099.     #pragma unused params
  1100.     #pragma unused help
  1101.     exitProperty(playerid);
  1102.     return 1;
  1103. }
  1104. YCMD:lock( playerid , params[] , help )
  1105. {
  1106.     #pragma unused params
  1107.     #pragma unused help
  1108.     lockProperty(playerid);
  1109.     return 1;
  1110. }
  1111.  
  1112. YCMD:alock( playerid , params[] , help )
  1113. {
  1114.     #pragma unused help
  1115.     new p,
  1116.         stat;
  1117.  
  1118.     if (sscanf(params, "dd", p , stat ))
  1119.     {
  1120.         return SendClientMessage(playerid, 0xFF0000AA, "Usage: (AdminLock) /alock [houseid] [1/0]");
  1121.     }
  1122.     if ( p == 0 || stat > 0 || stat > 2 )
  1123.     {
  1124.         return SendClientMessage(playerid, 0xFF0000AA, "Usage: (AdminLock) /alock [houseid] [1/0] (2if)");
  1125.     }
  1126.     else
  1127.     {
  1128.         if( stat == 0 )
  1129.         {
  1130.             propertyStats[p][DOOR] = stat;
  1131.             new str[80];
  1132.             format( str , 80 , "You have just {5EAF03}unlocked {FFFFFF}property id %d" , p );
  1133.             SendClientMessage(playerid, 0xFF0000AA, str);
  1134.         }
  1135.         if( stat == 1 )
  1136.         {
  1137.             propertyStats[p][DOOR] = stat;
  1138.             new str[80];
  1139.             format( str , 80 , "You have just {D32C2C}locked {FFFFFF}property id %d" , p );
  1140.             SendClientMessage(playerid, 0xFF0000AA, str);
  1141.         }
  1142.         if( stat == 2 )
  1143.         {
  1144.             propertyStats[p][DOOR] = stat;
  1145.             new str[80];
  1146.             format( str , 80 , "You have just the property(%d) stats to {D32C2C}door broken down" , p );
  1147.             SendClientMessage(playerid, 0xFF0000AA, str);
  1148.         }
  1149.     }
  1150.     return 1;
  1151. }
  1152. /*YCMD:rentroom( playerid , params[] , help )
  1153. {
  1154.     #pragma unused params
  1155.     #pragma unused help
  1156.     rentProperty( playerid );
  1157.     return 1;
  1158. }*/
  1159. YCMD:sp( playerid , params[] , help )
  1160. {
  1161.     #pragma unused playerid
  1162.     #pragma unused help
  1163.     saveProperty( strval(params) );
  1164.     return 1;
  1165. }
  1166. YCMD:buyproperty( playerid , params[] , help )
  1167. {
  1168.     #pragma unused params
  1169.     #pragma unused help
  1170.     buyProperty( playerid );
  1171.     return 1;
  1172. }
  1173. YCMD:sellproperty( playerid , params[] , help )
  1174. {
  1175.     #pragma unused params
  1176.     #pragma unused help
  1177.     sellProperty( playerid );
  1178.     return 1;
  1179. }
  1180. YCMD:jetpack( playerid , params[] , help )
  1181. {
  1182.     #pragma unused params
  1183.     #pragma unused help
  1184.     SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USEJETPACK);
  1185.     GameTextForPlayer( playerid , "~w~JetPack ~r~YO", 3, 3 );
  1186.     return 1;
  1187. }
  1188. YCMD:v( playerid , params[] , help )
  1189. {
  1190.     #pragma unused playerid
  1191.     #pragma unused help
  1192.     new id, c1, c2;
  1193.     if( sscanf( params , "ddd" , id , c1 , c2 ) )
  1194.     {
  1195.         SendClientMessage(playerid , -1 , "{AAFFAA}/v [model] [color1] [color2]" );
  1196.     }
  1197.     new Float:x,Float:y,Float:z,Float:a;
  1198.     GetPlayerFacingAngle(playerid , a);
  1199.     GetPlayerPos( playerid , x , y, z);
  1200.     CreateVehicle( id , x, y, z , a, c1, c2, 999*999*999);
  1201.     return 1;
  1202. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement