Guest User

ToD

a guest
Feb 26th, 2009
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.49 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dutils>
  3. #include <dudb>
  4. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  5.  
  6. //Colors//
  7. #define COLOR_SYSTEM 0xEFEFF7AA
  8. #define green 0x33FF33AA
  9. #define blue 0x00FFFFAA
  10. #define COLOR_GREEN 0x33AA33AA
  11. #define COLOR_RED 0xAA3333AA
  12.  
  13.  
  14. enum PlayerStat
  15. {
  16. Kills,
  17. Deaths
  18. };
  19.  
  20. new PlayerStats[MAX_PLAYERS][PlayerStat];
  21.  
  22. new joined[MAX_PLAYERS];
  23.  
  24. new put[MAX_PLAYERS] = 0;
  25.  
  26. new weap[MAX_PLAYERS] = 0;
  27.  
  28. new gived[MAX_PLAYERS] = 0;
  29.  
  30. #pragma tabsize 0
  31. #pragma unused strtok
  32. #if defined FILTERSCRIPT
  33.  
  34. #endif
  35.  
  36. public OnPlayerRequestSpawn(playerid)
  37. {
  38. if (udb_Exists(PlayerName(playerid)))
  39. {
  40. if (!joined[playerid]){
  41. return 0;
  42. }
  43. }
  44. return 1;
  45. }
  46.  
  47. public OnPlayerDisconnect(playerid)
  48. {
  49. if (joined[playerid]) //If the player logged in
  50. {
  51. SavePlayerPosition(playerid); //Position Saving
  52. SavePlayerWeapon(playerid); //Weapon Saving
  53. dUserSetINT(PlayerName(playerid)).("score",GetPlayerScore(playerid)); //Save Score
  54. dUserSetINT(PlayerName(playerid)).("money",GetPlayerMoney(playerid)); //Save Money
  55. dUserSetINT(PlayerName(playerid)).("kills",PlayerStats[playerid][Kills]); //Save Kills
  56. dUserSetINT(PlayerName(playerid)).("deaths",PlayerStats[playerid][Deaths]); //Save Deaths
  57. new Float:health;
  58. GetPlayerHealth(playerid, Float:health);
  59. new Float:armour;
  60. GetPlayerArmour(playerid, Float:armour);
  61. dUserSetINT(PlayerName(playerid)).("health",floatround(health)); //Save Health
  62. dUserSetINT(PlayerName(playerid)).("armour",floatround(armour)); //Save Armour
  63. dUserSetINT(PlayerName(playerid)).("skin",GetPlayerSkin(playerid)); //Save Skin
  64. dUserSetINT(PlayerName(playerid)).("color",GetPlayerColor(playerid)); //Save Color
  65. dUserSetINT(PlayerName(playerid)).("wanted",GetPlayerWantedLevel(playerid)); //Save WantedLevel
  66. dUserSetINT(PlayerName(playerid)).("virtual",GetPlayerVirtualWorld(playerid)); //Save VirtualWorld
  67. joined[playerid]=0;
  68. put[playerid]=0;
  69. weap[playerid]=0;
  70. gived[playerid]=0;
  71.  
  72.  
  73.  
  74. }
  75.  
  76. return false;
  77. }
  78.  
  79.  
  80. public OnPlayerConnect(playerid)
  81. {
  82. PlayerStats[playerid][Deaths] = 0;
  83. PlayerStats[playerid][Kills] = 0;
  84. }
  85.  
  86. public OnPlayerDeath(playerid, killerid, reason)
  87. {
  88. if (joined[playerid]) //If the player logged in
  89. {
  90. PlayerStats[playerid][Deaths]++;
  91. dUserSetINT(PlayerName(playerid)).("skin",GetPlayerSkin(playerid)); //Save Skin
  92. dUserSetINT(PlayerName(playerid)).("color",GetPlayerColor(playerid)); //Save Color
  93. dUserSetINT(PlayerName(playerid)).("wanted",GetPlayerWantedLevel(playerid)); //Save WantedLevel
  94. dUserSetINT(PlayerName(playerid)).("virtual",GetPlayerVirtualWorld(playerid)); //Save VirtualWorld
  95. SavePlayerPosition(playerid);
  96. }
  97. if (joined[killerid]) //If the killer logged in
  98. {
  99. PlayerStats[killerid][Kills]++;
  100. }
  101. return 1;
  102. }
  103.  
  104. public OnPlayerCommandText(playerid, cmdtext[])
  105. {
  106. dcmd(login,5,cmdtext);
  107. dcmd(register,8,cmdtext);
  108.  
  109.  
  110. return 0;
  111. }
  112.  
  113. public OnPlayerSpawn(playerid)
  114. {
  115. if (joined[playerid] && gived[playerid] == 0) //If the player logged in
  116. {
  117. GiveSavedWeapon(playerid);
  118. PutPlayerPosition(playerid);
  119. SetPlayerHealth(playerid, float(dUserINT(PlayerName(playerid)).("health"))); //Load Health
  120. SetPlayerArmour(playerid, float(dUserINT(PlayerName(playerid)).("armour"))); // Load Armour
  121. SetPlayerSkin(playerid,dUserINT(PlayerName(playerid)).("skin")); //Load Skin
  122. SetPlayerColor(playerid,dUserINT(PlayerName(playerid)).("color")); //Load Color
  123. SetPlayerWantedLevel(playerid,dUserINT(PlayerName(playerid)).("wanted")); //Load WantedLevel
  124. SetPlayerVirtualWorld(playerid,dUserINT(PlayerName(playerid)).("virtual")); //Load VirtualWorld
  125. gived[playerid]=1;
  126. }
  127. if (joined[playerid] && gived[playerid] == 1) //If the player logged in
  128. {
  129. PutPlayerPosition(playerid);
  130. SetPlayerSkin(playerid,dUserINT(PlayerName(playerid)).("skin")); //Load Skin
  131. SetPlayerColor(playerid,dUserINT(PlayerName(playerid)).("color")); //Load Color
  132. SetPlayerWantedLevel(playerid,dUserINT(PlayerName(playerid)).("wanted")); //Load WantedLevel
  133. SetPlayerVirtualWorld(playerid,dUserINT(PlayerName(playerid)).("virtual")); //Load VirtualWorld
  134. }
  135. return 1;
  136. }
  137.  
  138.  
  139.  
  140. stock SystemMsg(playerid,msg[]) {
  141. if ((IsPlayerConnected(playerid))&&(strlen(msg)>0)) {
  142. SendClientMessage(playerid,COLOR_SYSTEM,msg);
  143. }
  144. return 1;
  145. }
  146.  
  147. stock PlayerName(playerid)
  148. {
  149. new name[128];
  150. GetPlayerName(playerid, name, 128);
  151. return name;
  152. }
  153.  
  154.  
  155. dcmd_register(playerid,params[])
  156. {
  157.  
  158.  
  159. if (joined[playerid]) return SystemMsg(playerid,"");
  160.  
  161.  
  162. if (udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"");
  163.  
  164.  
  165. if (strlen(params)==0) return SystemMsg(playerid,"");
  166.  
  167.  
  168. if (udb_Create(PlayerName(playerid),params)) return SystemMsg(playerid,"");
  169. return true;
  170.  
  171. }
  172.  
  173.  
  174. dcmd_login(playerid,params[])
  175. {
  176.  
  177. if (joined[playerid]) return SystemMsg(playerid,"");
  178.  
  179. if (!udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"");
  180.  
  181. if (strlen(params)==0) return SystemMsg(playerid,"");
  182.  
  183. if (udb_CheckLogin(PlayerName(playerid),params))
  184. {
  185.  
  186. SetPlayerScore(playerid,dUserINT(PlayerName(playerid)).("score")); //Load Score
  187. GivePlayerMoney(playerid, dUserINT(PlayerName(playerid)).("money")); //Load Money
  188. PlayerStats[playerid][Deaths] = (dUserINT(PlayerName(playerid)).("deaths")); //Load Deaths
  189. PlayerStats[playerid][Kills] = (dUserINT(PlayerName(playerid)).("kills")); // Load Kills
  190.  
  191. joined[playerid]=1;
  192.  
  193. return SystemMsg(playerid,"");
  194. }
  195. // login was incorrect
  196. return SystemMsg(playerid,"");
  197. }
  198.  
  199.  
  200. SavePlayerPosition(playerid)
  201. {
  202.  
  203. new Float:x,Float:y,Float:z, interior;
  204. GetPlayerPos(playerid,x,y,z);
  205. interior = GetPlayerInterior(playerid);
  206. dUserSetINT(PlayerName(playerid)).("x1",floatround(x)); //Player's X
  207. dUserSetINT(PlayerName(playerid)).("y1",floatround(y)); //Player's Y
  208. dUserSetINT(PlayerName(playerid)).("z1",floatround(z)); //Player's Z
  209. dUserSetINT(PlayerName(playerid)).("interior1",interior); //Player's Interior
  210. }
  211.  
  212. PutPlayerPosition(playerid)
  213. {
  214. if (dUserINT(PlayerName(playerid)).("x1")!=0)
  215. {
  216. if(put[playerid]==0)
  217. {
  218. SetPlayerPos(playerid, float(dUserINT(PlayerName(playerid)).("x1")), float(dUserINT(PlayerName(playerid)).("y1")), float(dUserINT(PlayerName(playerid)).("z1")) );
  219. SetPlayerInterior(playerid, (dUserINT(PlayerName(playerid)).("interior1")) );
  220. put[playerid]=1;
  221. }
  222. }
  223. }
  224.  
  225. SavePlayerWeapon(playerid)
  226. {
  227.  
  228.  
  229. new weap1, ammo1, weap2, ammo2, weap3, ammo3, weap4, ammo4, weap5, ammo5, weap6, ammo6;
  230. GetPlayerWeaponData(playerid,2,weap1,ammo1);
  231. GetPlayerWeaponData(playerid,3,weap2,ammo2);
  232. GetPlayerWeaponData(playerid,4,weap3,ammo3);
  233. GetPlayerWeaponData(playerid,5,weap4,ammo4);
  234. GetPlayerWeaponData(playerid,6,weap5,ammo5);
  235. GetPlayerWeaponData(playerid,7,weap6,ammo6);
  236. dUserSetINT(PlayerName(playerid)).("weap1",weap1); dUserSetINT(PlayerName(playerid)).("weap1ammo",ammo1);
  237. dUserSetINT(PlayerName(playerid)).("weap2",weap2); dUserSetINT(PlayerName(playerid)).("weap2ammo",ammo2);
  238. dUserSetINT(PlayerName(playerid)).("weap3",weap3); dUserSetINT(PlayerName(playerid)).("weap3ammo",ammo3);
  239. dUserSetINT(PlayerName(playerid)).("weap4",weap4); dUserSetINT(PlayerName(playerid)).("weap4ammo",ammo4);
  240. dUserSetINT(PlayerName(playerid)).("weap5",weap5); dUserSetINT(PlayerName(playerid)).("weap5ammo",ammo5);
  241. dUserSetINT(PlayerName(playerid)).("weap6",weap6); dUserSetINT(PlayerName(playerid)).("weap6ammo",ammo6);
  242.  
  243. }
  244.  
  245. GiveSavedWeapon(playerid)
  246. {
  247. if (dUserINT(PlayerName(playerid)).("weap1")!=0)
  248. {
  249. if(weap[playerid]==0)
  250. {
  251. GivePlayerWeapon(playerid, dUserINT(PlayerName(playerid)).("weap1"), dUserINT(PlayerName(playerid)).("weap1ammo") );
  252. GivePlayerWeapon(playerid, dUserINT(PlayerName(playerid)).("weap2"), dUserINT(PlayerName(playerid)).("weap2ammo") );
  253. GivePlayerWeapon(playerid, dUserINT(PlayerName(playerid)).("weap3"), dUserINT(PlayerName(playerid)).("weap3ammo") );
  254. GivePlayerWeapon(playerid, dUserINT(PlayerName(playerid)).("weap4"), dUserINT(PlayerName(playerid)).("weap4ammo") );
  255. GivePlayerWeapon(playerid, dUserINT(PlayerName(playerid)).("weap5"), dUserINT(PlayerName(playerid)).("weap5ammo") );
  256. GivePlayerWeapon(playerid, dUserINT(PlayerName(playerid)).("weap6"), dUserINT(PlayerName(playerid)).("weap6ammo") );
  257. weap[playerid]=1;
  258. }
  259. }
  260. }
  261.  
  262.  
  263.  
  264.  
Advertisement
Add Comment
Please, Sign In to add comment