Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <zcmd>
- #define name "Glasses Shop"
- #define ver "v 1"
- #define by "by Sk47"
- #define PRESSED(%0) \
- ((newkeys & (%0)) == (%0))
- #define GLASSES_COST 100
- new Glasses[MAX_PLAYERS];
- new Timer[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- print("------------------------------------------------");
- printf("%s %s %s ",name,ver,by);
- print("------------------------------------------------");
- return 1;
- }
- COMMAND:glasses(playerid,params[])
- {
- new Float:p[3];
- GetPlayerPos(playerid,p[0],p[1],p[2]);
- SetPVarFloat(playerid,"PosX",p[0]);
- SetPVarFloat(playerid,"PosY",p[1]);
- SetPVarFloat(playerid,"PosZ",p[2]);
- SetPVarInt(playerid,"Inter",GetPlayerInterior(playerid));
- SetPVarInt(playerid,"Virtual",GetPlayerVirtualWorld(playerid));
- SetPVarInt(playerid,"BuyGlasses",1);
- Glasses[playerid] = 19006;
- SetPlayerInterior(playerid,15);
- SetPlayerPos(playerid,218.6603,-98.6067,1005.2578);
- SetPlayerFacingAngle(playerid,271.3023);
- SetPlayerCameraPos(playerid,217.6669,-97.8175,1005.8);
- SetPlayerCameraLookAt(playerid,218.6638,-98.2785,1005.8);
- TogglePlayerControllable(playerid,false);
- Timer[playerid] = SetTimerEx("LeftAndRight",100,1,"i",playerid);
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(PRESSED(KEY_SECONDARY_ATTACK) && GetPVarInt(playerid,"BuyGlasses") == 1)
- {
- Glasses[playerid] = 0;
- RemovePlayerAttachedObject(playerid, 2);
- SetPlayerAttachedObject(playerid,2,GetPVarInt(playerid,"BuysGlasses"), 2, 0.1, 0.03, 0.0, 0.0, 90.0, 90.0);
- TogglePlayerControllable(playerid,true);
- SetCameraBehindPlayer(playerid);
- KillTimer(Timer[playerid]);
- SetPVarInt(playerid,"BuyGlasses",0);
- SetPlayerPos(playerid,GetPVarFloat(playerid,"PosX"),
- GetPVarFloat(playerid,"PosY"),GetPVarFloat(playerid,"PosZ"));
- SetPlayerInterior(playerid,GetPVarInt(playerid,"Inter"));
- SetPlayerVirtualWorld(playerid,GetPVarInt(playerid,"Virtual"));
- }
- if(PRESSED(KEY_SPRINT) && GetPVarInt(playerid,"BuyGlasses") == 1)
- {
- if(GetPlayerMoney(playerid) < GLASSES_COST) return
- SendClientMessage(playerid,0xFFFFFFFF,"У вас не хватает денег");
- RemovePlayerAttachedObject(playerid, 2);
- SetPlayerAttachedObject(playerid,2,Glasses[playerid], 2, 0.1, 0.03, 0.0, 0.0, 90.0, 90.0);
- GivePlayerMoney(playerid, - GLASSES_COST);
- TogglePlayerControllable(playerid,true);
- SetCameraBehindPlayer(playerid);
- KillTimer(Timer[playerid]);
- SetPVarInt(playerid,"BuyGlasses",0);
- SetPlayerPos(playerid,GetPVarFloat(playerid,"PosX"),
- GetPVarFloat(playerid,"PosY"),GetPVarFloat(playerid,"PosZ"));
- SetPlayerInterior(playerid,GetPVarInt(playerid,"Inter"));
- SetPlayerVirtualWorld(playerid,GetPVarInt(playerid,"Virtual"));
- }
- return 1;
- }
- forward LeftAndRight(playerid);
- public LeftAndRight(playerid)
- {
- new key,ud,lr;
- GetPlayerKeys(playerid,key,ud,lr);
- if(lr > 0 && GetPVarInt(playerid,"BuyGlasses") == 1)
- {
- if(Glasses[playerid] == 19035)
- {
- Glasses[playerid] = 19006;
- }
- else
- {
- Glasses[playerid] ++;
- }
- RemovePlayerAttachedObject(playerid, 2);
- SetPlayerAttachedObject(playerid,2,Glasses[playerid], 2, 0.1, 0.03, 0.0, 0.0, 90.0, 90.0);
- }
- if(lr < 0 && GetPVarInt(playerid,"BuyGlasses") == 1)
- {
- if(Glasses[playerid] == 19006)
- {
- Glasses[playerid] = 19035;
- }
- else
- {
- Glasses[playerid] --;
- }
- RemovePlayerAttachedObject(playerid, 2);
- SetPlayerAttachedObject(playerid,2,Glasses[playerid], 2, 0.1, 0.03, 0.0, 0.0, 90.0, 90.0);
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid)
- {
- KillTimer(Timer[playerid]);
- RemovePlayerAttachedObject(playerid, 2);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement