Guest User

Untitled

a guest
Oct 31st, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.49 KB | None | 0 0
  1. protected OnPresentCreated( createID )
  2. {
  3. presentsInfo[ createID ][ presSQLID ] = cache_insert_id();
  4. return(true);
  5. }
  6. // --
  7. protected OnPresentsLoad( )
  8. {
  9. new rows, fields, thisID, rowsCounter = 1;
  10. cache_get_data( rows, fields, mSQL );
  11.  
  12. if( rows )
  13. {
  14. for( new i = 0; i < rows; i ++ )
  15. {
  16. thisID = rowsCounter;
  17.  
  18. presentsInfo[ thisID ][ presSQLID ] = cache_get_field_content_int( i, "presSQLID" );
  19. presentsInfo[ thisID ][ presTaken ] = bool:cache_get_field_content_int( i, "presTaken" );
  20. presentsInfo[ thisID ][ presPlaced ] = bool:cache_get_field_content_int( i, "presPlaced" );
  21. presentsInfo[ thisID ][ presPos ][ 0 ] = cache_get_field_content_float( i, "presPos1" );
  22. presentsInfo[ thisID ][ presPos ][ 1 ] = cache_get_field_content_float( i, "presPos2" );
  23. presentsInfo[ thisID ][ presPos ][ 2 ] = cache_get_field_content_float( i, "presPos3" );
  24. presentsInfo[ thisID ][ presPos ][ 3 ] = cache_get_field_content_float( i, "presPos4" );
  25. presentsInfo[ thisID ][ presPos ][ 4 ] = cache_get_field_content_float( i, "presPos5" );
  26. presentsInfo[ thisID ][ presPos ][ 5 ] = cache_get_field_content_float( i, "presPos6" );
  27.  
  28. new string[50];
  29. if( presentsInfo[ thisID ][ presPlaced ] )
  30. {
  31. new object = 19054;
  32. new rand = random( 5 );
  33. switch( rand )
  34. {
  35. case 0: object = 19054;
  36. case 1: object = 19055;
  37. case 2: object = 19056;
  38. case 3: object = 19057;
  39. case 4: object = 19058;
  40. }
  41.  
  42. if( !presentsInfo[ thisID ][ presTaken ] )
  43. {
  44. format( string,sizeof( string ), "(/poklon)" );
  45. presentsInfo[ thisID ][ pres3d ] = CreateDynamic3DTextLabel( string, 0x00FF00FF, presentsInfo[ thisID ][ presPos ][ 0 ], presentsInfo[ thisID ][ presPos ][ 1 ], presentsInfo[ thisID ][ presPos ][ 2 ], 3.0, IPI, IVI, 0, 0, 0 );
  46. presentsInfo[ thisID ][ presObject ] = CreateDynamicObject( object, presentsInfo[ thisID ][ presPos ][ 0 ], presentsInfo[ thisID ][ presPos ][ 1 ], presentsInfo[ thisID ][ presPos ][ 2 ], presentsInfo[ thisID ][ presPos ][ 3 ], presentsInfo[ thisID ][ presPos ][ 4 ], presentsInfo[ thisID ][ presPos ][ 5 ] );
  47. }
  48. else if( presentsInfo[ thisID ][ presTaken ] )
  49. {
  50. format( string, sizeof( string ), "Poklon je otvoren." );
  51. presentsInfo[ thisID ][ pres3d ] = CreateDynamic3DTextLabel( string, 0xFF0000FF, presentsInfo[ thisID ][ presPos ][ 0 ], presentsInfo[ thisID ][ presPos ][ 1 ], presentsInfo[ thisID ][ presPos ][ 2 ], 3.0, IPI, IVI, 0, 0, 0 );
  52. presentsInfo[ thisID ][ presObject ] = CreateDynamicObject( object, presentsInfo[ thisID ][ presPos ][ 0 ], presentsInfo[ thisID ][ presPos ][ 1 ], presentsInfo[ thisID ][ presPos ][ 2 ], presentsInfo[ thisID ][ presPos ][ 3 ], presentsInfo[ thisID ][ presPos ][ 4 ], presentsInfo[ thisID ][ presPos ][ 5 ] );
  53. }
  54. }
  55. rowsCounter++;
  56. }
  57. }
  58.  
  59. //
  60. new i = 0;
  61. for( new j = 1; j < MAX_PRESENTS; j++ )
  62. {
  63. if( presentsInfo[ j ][ presSQLID ] == -1 )
  64. {
  65. i = j;
  66. break;
  67. }
  68. }
  69. if( i != 0 ) return SendErrorMessage( playerid, "Vec je jedan poklon u procesu izgradnje, nije dovrsen, sacekajte(sigurnost baze)." );
  70.  
  71. i = -1;
  72. for( new j = 1; j < MAX_PRESENTS; i++)
  73. {
  74. if( presentsInfo[ j ][ presSQLID ] == 0 )
  75. {
  76. i = j;
  77. break;
  78. }
  79. }
  80. if( presentsInfo[ (MAX_PRESENTS-1) ][ presSQLID ] != 0 ) return SendErrorMessage( playerid, "Ima maksimalno kreiranih poklona." );
  81.  
  82. if( presentsInfo[i][presSQLID] != 0 ) return SendErrorMessage( playerid, "ID tog poklona vec postoji." );
  83.  
  84. new Float:x, Float:y, Float:z, Float:angle;
  85. GetPlayerPos( playerid, x, y, z);
  86. GetPlayerFacingAngle( playerid, angle );
  87. presentsInfo[ i ][ presPos ][ 0 ] = x;
  88. presentsInfo[ i ][ presPos ][ 1 ] = y;
  89. presentsInfo[ i ][ presPos ][ 2 ] = z;
  90. presentsInfo[ i ][ presPos ][ 3 ] = 0;
  91. presentsInfo[ i ][ presPos ][ 4 ] = 0;
  92. presentsInfo[ i ][ presPos ][ 5 ] = 0;
  93. presentsInfo[ i ][ presTaken ] = false;
  94. presentsInfo[ i ][ presObject ] = CreateDynamicObject( 19054, x+2, y, z+0.6, 0.0, 0.0, angle );
  95. Streamer_Update( playerid );
  96. EditDynamicObject( playerid, presentsInfo[ i ][ presObject ] );
  97. EditPresents[ playerid ] = i;
  98. mSQL_CreatePresent( i );
  99. #else
  100. SendErrorMessage( playerid, "Nije ukljucen zimski mod." );
  101. #endif
  102. }
Advertisement
Add Comment
Please, Sign In to add comment