Advertisement
Guest User

Untitled

a guest
Dec 29th, 2010
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.64 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3.  
  4. #define name "Glasses Shop"
  5. #define ver "v 1"
  6. #define by "by Sk47"
  7. #define PRESSED(%0) \
  8. ((newkeys & (%0)) == (%0))
  9. #define GLASSES_COST 100
  10.  
  11. new Glasses[MAX_PLAYERS];
  12. new Timer[MAX_PLAYERS];
  13.  
  14. public OnFilterScriptInit()
  15. {
  16. print("------------------------------------------------");
  17. printf("%s %s %s ",name,ver,by);
  18. print("------------------------------------------------");
  19. return 1;
  20. }
  21.  
  22. COMMAND:glasses(playerid,params[])
  23. {
  24. new Float:p[3];
  25. GetPlayerPos(playerid,p[0],p[1],p[2]);
  26. SetPVarFloat(playerid,"PosX",p[0]);
  27. SetPVarFloat(playerid,"PosY",p[1]);
  28. SetPVarFloat(playerid,"PosZ",p[2]);
  29. SetPVarInt(playerid,"Inter",GetPlayerInterior(playerid));
  30. SetPVarInt(playerid,"Virtual",GetPlayerVirtualWorld(playerid));
  31. SetPVarInt(playerid,"BuyGlasses",1);
  32. Glasses[playerid] = 19006;
  33. SetPlayerInterior(playerid,15);
  34. SetPlayerPos(playerid,218.6603,-98.6067,1005.2578);
  35. SetPlayerFacingAngle(playerid,271.3023);
  36. SetPlayerCameraPos(playerid,217.6669,-97.8175,1005.8);
  37. SetPlayerCameraLookAt(playerid,218.6638,-98.2785,1005.8);
  38. TogglePlayerControllable(playerid,false);
  39. Timer[playerid] = SetTimerEx("LeftAndRight",100,1,"i",playerid);
  40. return 1;
  41. }
  42. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  43. {
  44. if(PRESSED(KEY_SECONDARY_ATTACK) && GetPVarInt(playerid,"BuyGlasses") == 1)
  45. {
  46. Glasses[playerid] = 0;
  47. RemovePlayerAttachedObject(playerid, 2);
  48. SetPlayerAttachedObject(playerid,2,GetPVarInt(playerid,"BuysGlasses"), 2, 0.1, 0.03, 0.0, 0.0, 90.0, 90.0);
  49. TogglePlayerControllable(playerid,true);
  50. SetCameraBehindPlayer(playerid);
  51. KillTimer(Timer[playerid]);
  52. SetPVarInt(playerid,"BuyGlasses",0);
  53. SetPlayerPos(playerid,GetPVarFloat(playerid,"PosX"),
  54. GetPVarFloat(playerid,"PosY"),GetPVarFloat(playerid,"PosZ"));
  55. SetPlayerInterior(playerid,GetPVarInt(playerid,"Inter"));
  56. SetPlayerVirtualWorld(playerid,GetPVarInt(playerid,"Virtual"));
  57. }
  58. if(PRESSED(KEY_SPRINT) && GetPVarInt(playerid,"BuyGlasses") == 1)
  59. {
  60. if(GetPlayerMoney(playerid) < GLASSES_COST) return
  61. SendClientMessage(playerid,0xFFFFFFFF,"У вас не хватает денег");
  62. RemovePlayerAttachedObject(playerid, 2);
  63. SetPlayerAttachedObject(playerid,2,Glasses[playerid], 2, 0.1, 0.03, 0.0, 0.0, 90.0, 90.0);
  64. GivePlayerMoney(playerid, - GLASSES_COST);
  65. TogglePlayerControllable(playerid,true);
  66. SetCameraBehindPlayer(playerid);
  67. KillTimer(Timer[playerid]);
  68. SetPVarInt(playerid,"BuyGlasses",0);
  69. SetPlayerPos(playerid,GetPVarFloat(playerid,"PosX"),
  70. GetPVarFloat(playerid,"PosY"),GetPVarFloat(playerid,"PosZ"));
  71. SetPlayerInterior(playerid,GetPVarInt(playerid,"Inter"));
  72. SetPlayerVirtualWorld(playerid,GetPVarInt(playerid,"Virtual"));
  73. }
  74. return 1;
  75. }
  76.  
  77. forward LeftAndRight(playerid);
  78. public LeftAndRight(playerid)
  79. {
  80. new key,ud,lr;
  81. GetPlayerKeys(playerid,key,ud,lr);
  82. if(lr > 0 && GetPVarInt(playerid,"BuyGlasses") == 1)
  83. {
  84. if(Glasses[playerid] == 19035)
  85. {
  86. Glasses[playerid] = 19006;
  87. }
  88. else
  89. {
  90. Glasses[playerid] ++;
  91. }
  92. RemovePlayerAttachedObject(playerid, 2);
  93. SetPlayerAttachedObject(playerid,2,Glasses[playerid], 2, 0.1, 0.03, 0.0, 0.0, 90.0, 90.0);
  94. }
  95. if(lr < 0 && GetPVarInt(playerid,"BuyGlasses") == 1)
  96. {
  97. if(Glasses[playerid] == 19006)
  98. {
  99. Glasses[playerid] = 19035;
  100. }
  101. else
  102. {
  103. Glasses[playerid] --;
  104. }
  105. RemovePlayerAttachedObject(playerid, 2);
  106. SetPlayerAttachedObject(playerid,2,Glasses[playerid], 2, 0.1, 0.03, 0.0, 0.0, 90.0, 90.0);
  107. }
  108. return 1;
  109. }
  110.  
  111. public OnPlayerDisconnect(playerid)
  112. {
  113. KillTimer(Timer[playerid]);
  114. RemovePlayerAttachedObject(playerid, 2);
  115. return 1;
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement