Advertisement
Guest User

Untitled

a guest
May 9th, 2011
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.52 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3.  
  4. #define name "Glasses Shop"
  5. #define ver "v 2"
  6. #define by "by Sk47"
  7. #define PRESSED(%0) \
  8.     ((newkeys & (%0)) == (%0))
  9. #define GLASSES_COST 100
  10.  
  11. new Text:Textdraw0;
  12. new Glasses[MAX_PLAYERS];
  13. new Timer[MAX_PLAYERS];
  14.  
  15. public OnFilterScriptInit()
  16. {
  17.     print("------------------------------------------------");
  18.     printf("%s %s %s ",name,ver,by);
  19.     print("------------------------------------------------");
  20.     Textdraw0 = TextDrawCreate(181.000000,364.000000,"~r~KEY RIGHT ~w~- Next Glasses~n~~r~KEY LEFT ~w~- Previos Glasses~n~~r~KEY SPRINT ~w~- Buy Glasses~n~~r~KEY ENTER ~w~- Exit");
  21.     TextDrawUseBox(Textdraw0,1);
  22.     TextDrawBoxColor(Textdraw0,0x000000cc);
  23.     TextDrawTextSize(Textdraw0,428.000000,10.000000);
  24.     TextDrawAlignment(Textdraw0,0);
  25.     TextDrawBackgroundColor(Textdraw0,0x000000ff);
  26.     TextDrawFont(Textdraw0,1);
  27.     TextDrawLetterSize(Textdraw0,0.499999,1.200000);
  28.     TextDrawColor(Textdraw0,0xffffffff);
  29.     TextDrawSetOutline(Textdraw0,1);
  30.     TextDrawSetProportional(Textdraw0,1);
  31.     TextDrawSetShadow(Textdraw0,1);
  32.     return 1;
  33. }
  34.  
  35. COMMAND:glasses(playerid,params[])
  36. {
  37.     new Float:p[3];
  38.     GetPlayerPos(playerid,p[0],p[1],p[2]);
  39.     SetPVarFloat(playerid,"PosX",p[0]);
  40.     SetPVarFloat(playerid,"PosY",p[1]);
  41.     SetPVarFloat(playerid,"PosZ",p[2]);
  42.     SetPVarInt(playerid,"Inter",GetPlayerInterior(playerid));
  43.     SetPVarInt(playerid,"Virtual",GetPlayerVirtualWorld(playerid));
  44.     SetPVarInt(playerid,"BuyGlasses",1);
  45.     Glasses[playerid] = 19006;
  46.     SetPlayerInterior(playerid,15);
  47.     SetPlayerPos(playerid,218.6603,-98.6067,1005.2578);
  48.     SetPlayerFacingAngle(playerid,271.3023);
  49.     SetPlayerCameraPos(playerid,217.6669,-97.8175,1005.8);
  50.     SetPlayerCameraLookAt(playerid,218.6638,-98.2785,1005.8);
  51.     TogglePlayerControllable(playerid,false);
  52.     Timer[playerid] = SetTimerEx("LeftAndRight",100,1,"i",playerid);
  53.     TextDrawShowForPlayer(playerid,Textdraw0);
  54.     return 1;
  55. }
  56. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  57. {
  58.     if(PRESSED(KEY_SECONDARY_ATTACK) && GetPVarInt(playerid,"BuyGlasses") == 1)
  59.     {
  60.         Glasses[playerid] = 0;
  61.         RemovePlayerAttachedObject(playerid, 2);
  62.         SetPlayerAttachedObject(playerid,2,GetPVarInt(playerid,"BuysGlasses"), 2, 0.1, 0.03, 0.0, 0.0, 90.0, 90.0);
  63.         TogglePlayerControllable(playerid,true);
  64.         SetCameraBehindPlayer(playerid);
  65.         KillTimer(Timer[playerid]);
  66.         SetPVarInt(playerid,"BuyGlasses",0);
  67.         SetPlayerPos(playerid,GetPVarFloat(playerid,"PosX"),
  68.         GetPVarFloat(playerid,"PosY"),GetPVarFloat(playerid,"PosZ"));
  69.         SetPlayerInterior(playerid,GetPVarInt(playerid,"Inter"));
  70.         SetPlayerVirtualWorld(playerid,GetPVarInt(playerid,"Virtual"));
  71.         TextDrawHideForPlayer(playerid,Textdraw0);
  72.     }
  73.     if(PRESSED(KEY_SPRINT) && GetPVarInt(playerid,"BuyGlasses") == 1)
  74.     {
  75.         if(GetPlayerMoney(playerid) < GLASSES_COST) return
  76.         SendClientMessage(playerid,0xFFFFFFFF,"У вас не хватает денег");
  77.         RemovePlayerAttachedObject(playerid, 2);
  78.         SetPlayerAttachedObject(playerid,2,Glasses[playerid], 2, 0.1, 0.03, 0.0, 0.0, 90.0, 90.0);
  79.         GivePlayerMoney(playerid, - GLASSES_COST);
  80.         TogglePlayerControllable(playerid,true);
  81.         SetCameraBehindPlayer(playerid);
  82.         KillTimer(Timer[playerid]);
  83.         SetPVarInt(playerid,"BuyGlasses",0);
  84.         SetPlayerPos(playerid,GetPVarFloat(playerid,"PosX"),
  85.         GetPVarFloat(playerid,"PosY"),GetPVarFloat(playerid,"PosZ"));
  86.         SetPlayerInterior(playerid,GetPVarInt(playerid,"Inter"));
  87.         SetPlayerVirtualWorld(playerid,GetPVarInt(playerid,"Virtual"));
  88.         TextDrawHideForPlayer(playerid,Textdraw0);
  89.     }
  90.     return 1;
  91. }
  92.  
  93. forward LeftAndRight(playerid);
  94. public LeftAndRight(playerid)
  95. {
  96.     new key,ud,lr;
  97.     GetPlayerKeys(playerid,key,ud,lr);
  98.     if(lr > 0  && GetPVarInt(playerid,"BuyGlasses") == 1)
  99.     {
  100.         if(Glasses[playerid] == 19035)
  101.         {
  102.             Glasses[playerid] = 19006;
  103.         }
  104.         else
  105.         {
  106.             Glasses[playerid] ++;
  107.         }
  108.         RemovePlayerAttachedObject(playerid, 2);
  109.         SetPlayerAttachedObject(playerid,2,Glasses[playerid], 2, 0.1, 0.03, 0.0, 0.0, 90.0, 90.0);
  110.     }
  111.     if(lr < 0  && GetPVarInt(playerid,"BuyGlasses") == 1)
  112.     {
  113.         if(Glasses[playerid] == 19006)
  114.         {
  115.             Glasses[playerid] = 19035;
  116.         }
  117.         else
  118.         {
  119.             Glasses[playerid] --;
  120.         }
  121.         RemovePlayerAttachedObject(playerid, 2);
  122.         SetPlayerAttachedObject(playerid,2,Glasses[playerid], 2, 0.1, 0.03, 0.0, 0.0, 90.0, 90.0);
  123.     }
  124.     return 1;
  125. }
  126.  
  127. public OnPlayerDisconnect(playerid)
  128. {
  129.     KillTimer(Timer[playerid]);
  130.     RemovePlayerAttachedObject(playerid, 2);
  131.     TextDrawHideForPlayer(playerid,Textdraw0);
  132.     return 1;
  133. }
  134.  
  135.  
  136. public OnFilterScriptExit()
  137. {
  138.     TextDrawDestroy(Textdraw0);
  139.     return 1;
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement