Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <ForEachPlayer>
- #include <GDFPTL>
- #define PRESSED(%0) \
- (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- #define RELEASED(%0) \
- (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
- static ShootingWithSniper[MAX_PLAYERS];
- static LastSniperShot[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- if(IsPlayerConnected(i) && !IsPlayerNPC(i))
- AddPlayer(i);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- ShootingWithSniper[playerid] = false;
- LastSniperShot[playerid] = GetTickCount();
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- ShootingWithSniper[playerid] = false;
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(!IsPlayerNPC(playerid) && PRESSED(KEY_FIRE) && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && GetPlayerWeapon(playerid) == 34)
- ShootingWithSniper[playerid] = true;
- else if(RELEASED(KEY_FIRE))
- ShootingWithSniper[playerid] = false;
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- new t = GetTickCount();
- if(ShootingWithSniper[playerid] && (t - LastSniperShot[playerid]) > 800)
- {
- new
- worldid = GetPlayerVirtualWorld(playerid),
- Float:x1,
- Float:y1,
- Float:z1,
- Float:x2,
- Float:y2,
- Float:z2,
- Float:distance,
- Float:cvx,
- Float:cvy,
- Float:cvz,
- Float:cx,
- Float:cy,
- Float:cz;
- GetPlayerCameraPos(playerid, cx, cy, cz);
- GetPlayerCameraFrontVector(playerid, cvx, cvy, cvz);
- GetPlayerPos(playerid, x1, y1, z1);
- LastSniperShot[playerid] = t;
- ForEachPlayer(i)
- {
- if(i != playerid && GetPlayerVirtualWorld(i) == worldid && IsPlayerInRangeOfPoint(i, 150.0, x1, y1, z1))
- {
- GetPlayerPos(i, x2, y2, z2);
- z2 = z2 + 0.675;
- GetDistanceFromPointToLine(distance, cvx, cvy, cvz, cx, cy, cz, x2, y2, z2);
- if(distance < 0.25)
- {
- SetPlayerHealth(i, 0.0);
- SetPlayerArmour(i, 0.0);
- GameTextForPlayer(playerid, "~y~BOOM!!!~n~~r~Headshot!", 2000, 4);
- GameTextForPlayer(i, "~y~BOOM!!!~n~~r~Headshot!", 2000, 4);
- return 1;
- }
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement