admin.inc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. static carstr[128];
  2. /*
  3. ****** Administrator Vehicle Commands *******
  4. ===================================================
  5. */
  6. CMD:checkcars( playerid, params[] ) {
  7. if( PlayerInfo[playerid][pAdmin] < 1 && PlayerInfo[playerid][pDev] < 3 ) {
  8. return SendClientMessage( playerid, COLOR_GREY, "You are not authorized to use this command." );
  9. }
  10. new player;
  11. if( sscanf( params, "u", player ) ) {
  12. return SendClientMessage( playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /checkvehicles [playerid/playerName]" );
  13. }
  14. if( !IsPlayerConnected(player) ) {
  15. return SendClientMessage( playerid, COLOR_GREY, "That player isn't connected." );
  16. }
  17. format( carstr, sizeof( carstr ), "_______[ %s's vehicles ]_______", PlayerICName( player ) );
  18. SendClientMessage( playerid, COLOR_LIGHTBLUE, carstr );
  19. new count;
  20. for( new i; i < PlayerInfo[player][pMaxCarSlots]; i++ ) {
  21. #define veh(%1) PlayerVehicles[player][i][pv%1]
  22. if( veh(SQLID) < 1 ) continue;
  23. //veh name
  24. format( carstr, sizeof( carstr ), "Car slot %d: %s (%s) [vehicleid: %d] %s", i+1, GetVehicleFriendlyNameFromModel( veh(model) ), veh(plate), veh(ID), ( veh(impounded) == 1 ) ? ( ( "- IMPOUNDED" ) ) : ( "" ) );
  25. SendClientMessage( playerid, COLOR_WHITE, carstr );
  26. //veh info
  27. format( carstr, sizeof( carstr ), " Upgrades: %s %s %s %s",
  28. ( veh(gps) == 1 ) ? ( ( "GPS" ) ) : ( "" ), ( veh(alarm) == 1 ) ? ( ( "Alarm" ) ) : ( "" ), ( veh(insurance) == 1 ) ? ( ( "Insurance" ) ) : ( "" ),
  29. ( veh(sparekey) == 1 ) ? ( ( "Spare key" ) ) : ( "" ) );
  30. SendClientMessage( playerid, COLOR_GREY, carstr );
  31. count++;
  32. #undef veh
  33. }
  34. if( count < 1 ) {
  35. SendClientMessage( playerid, COLOR_GREY, "This player doesn't own any vehicles." );
  36. }
  37. SendClientMessage( playerid, COLOR_GREY, "________________________________" );
  38. return 1;
  39. }
  40. //========================[ Managing player vehicles ]=========================
  41. CMD:givecar( playerid, params[] ) {
  42. if( PlayerInfo[playerid][pAdmin] < 4 ) {
  43. return SendClientMessage( playerid, COLOR_GREY, "You are not authorized to use this." );
  44. }
  45. new player, model[128];
  46. if( sscanf( params, "us[128]", player, model ) ) {
  47. return SendClientMessage( playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /givecar [playerid/name] [vehicleName/ID]" );
  48. }
  49. if( !IsPlayerConnected( player ) ) {
  50. return SendClientMessage( playerid, COLOR_GREY, "That player isn't connected." );
  51. }
  52. new modelid = ReturnVehicleModelID( model );
  53. new slot = GetPlayerFreeCarslot( player );
  54. if( slot == -1 ) {
  55. return SendClientMessage( playerid, COLOR_GREY, "That player has no more room for more cars." );
  56. }
  57. new Float:pos[4];
  58. GetPlayerPos( playerid, pos[0], pos[1], pos[2] );
  59. GetPlayerFacingAngle( playerid, pos[3] );
  60. createPlayerVehicle( player, slot, modelid, pos[0] + 5, pos[1], pos[2], pos[3] );
  61. new isspawned = GetPlayerSpawnedVehicleSlot( playerid );
  62. if( isspawned > -1 ) {
  63. destroyPlayerVehicle( player, isspawned );
  64. }
  65. spawnPlayerVehicle( player, slot );
  66. new vehstr[128];
  67. format( vehstr, sizeof( vehstr ), "You have given %s a %s.", PlayerICName( player ), GetVehicleFriendlyNameFromModel( modelid ) );
  68. SendClientMessage( playerid, COLOR_GREY, vehstr );
  69. SendClientMessage( playerid, COLOR_GREY, "Notify the player of the location of their parked car (here). It will spawn when they tow it." );
  70. format( vehstr, sizeof( vehstr ), "%s has given you a %s. It's now accessable in /v, it will spawn at the admin's position." , PlayerICName( playerid ), GetVehicleFriendlyNameFromModel( modelid ) );
  71. SendClientMessage( player, COLOR_LIGHTBLUE, vehstr );
  72. return 1;
  73. }
  74. CMD:removecar( playerid, params[] ) {
  75. if( PlayerInfo[playerid][pAdmin] < 4 ) {
  76. return 1;
  77. }
  78. new player, slot;
  79. if( sscanf( params, "ui", player, slot ) ) {
  80. return SendClientMessage( playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /removecar [playerID/playerName] [slot]" );
  81. }
  82. if( slot > PlayerInfo[player][pMaxCarSlots] || slot < 1 ) {
  83. return SendClientMessage( playerid, COLOR_GREY, "You must enter a valid car slot (between 1 and 3). HINT: see /checkcars." );
  84. }
  85. if( !IsPlayerConnected( player ) ) {
  86. return SendClientMessage( playerid, COLOR_GREY, "That player is not connected." );
  87. }
  88. new car_str[128];
  89. slot--;
  90. #define veh(%0) PlayerVehicles[player][slot][pv%0]
  91. if( veh(SQLID) < 1 ) {
  92. return SendClientMessage( playerid, COLOR_GREY, "This player doesn't have a vehicle in this slot." );
  93. }
  94. format( car_str, 128, "You have destroyed %s's %s.", PlayerICName( player ), GetVehicleFriendlyNameFromModel( veh(model) ) );
  95. SendClientMessage( playerid, COLOR_GREY, car_str );
  96. //Destroy the vehicle completely & despawn it
  97. ResetPlayerVehicleSlot( player, slot );
  98. #undef veh
  99. return 1;
  100. }
  101. CMD:oldvehicle( playerid, params[] ) {
  102. if( PlayerInfo[playerid][pAdmin] < 1 && PlayerInfo[playerid][pDev] < 1 ) {
  103. return 1;
  104. }
  105. new targetid;
  106. if( sscanf( params, "i", targetid ) ) {
  107. return SendClientMessage( playerid, COLOR_GREY, "USAGE:/oldvehicle [car key(ID)]" );
  108. }
  109. if( !IsPlayerConnected( targetid ) ) {
  110. return SendClientMessage( playerid, COLOR_GREY, "Invalid player ID." );
  111. }
  112. new query[300];
  113. mysql_format( sqlGameConnection, query, sizeof( query ), "SELECT CKey1, CKey2 FROM players2 WHERE ID = %d", PlayerInfo[targetid][pID] );
  114. mysql_pquery( sqlGameConnection, query, "VehicleRefund", "ii", playerid, targetid);
  115. return 1;
  116. }
  117. forward VehicleRefund( playerid, id );
  118. public VehicleRefund( playerid, id ) {
  119. new rows, fields, CKey[2];
  120. cache_get_data( rows, fields );
  121. if( !rows ) {
  122. return SendClientMessage( playerid, COLOR_GREY, "Provided playerid not found." );
  123. }
  124. CKey[0] = cache_get_field_content_int( 0, "CKey1" );
  125. CKey[1] = cache_get_field_content_int( 0, "CKey2" );
  126. printf("oldvehicles: Ckey1: %d, CKey2: %d", CKey[0], CKey[1] );
  127. for( new i; i < sizeof( CKey ); i++ ) {
  128. new strFile[48];
  129. format(strFile, sizeof(strFile), "cars/%d.ini", CKey[i] );
  130. if(!fexist(strFile)) {
  131. return SendClientMessage( playerid, COLOR_GREY, "The old vehicle does not exist." );
  132. }
  133. new model;
  134. new File:fCar = fopen(strFile, io_read);
  135. new strData[128], strKey[128];
  136. while(fread(fCar, strData, sizeof(strData)))
  137. {
  138. strKey = ini_GetKey(strData);
  139. if(strcmp(strKey, "Model") == 0) model = strvalEx(ini_GetValue(strData));
  140. }
  141. fclose(fCar);
  142. new output[128];
  143. format( output, 128, "The old vehicle model of slot %d was: %d", i, model );
  144. SendClientMessage( playerid, COLOR_GREY, output );
  145. }
  146. return 1;
  147. }