Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Grenade Launcher v1.0
- Made by Jelly23
- */
- /*Defined as filterscript*/
- #define FILTERSCRIPT
- /*Includes*/
- #include <a_samp>
- #include <izcmd>
- #include <MapAndreas>
- /*Vars*/
- new Float:aPos[MAX_PLAYERS],
- stage[MAX_PLAYERS],
- TotalGrenades = -1;
- /*Do not touch*/
- #define player_dist 0.1
- #define launch_dist 10.0
- #define grenade_dist 15.0
- /*Enumerator*/
- enum Grenades
- {
- GrenadeObj,
- gPlayer
- }
- new gData[MAX_OBJECTS][Grenades];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Grenade Launcher v1.0 - Made by Jelly23");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if (newkeys & KEY_WALK)
- {
- if(GetPlayerWeapon(playerid) == 31)
- {
- if(IsPlayerAiming(playerid))
- {
- if(stage[playerid] == 0)
- {
- new Float:x, Float:y, Float:z;
- TotalGrenades++;
- GetPlayerPos(playerid, x, y, z);
- stage[playerid] = 1;
- GetPlayerPos(playerid, x, y, aPos[playerid]);
- GetPlayerFacingAngle(playerid, aPos[playerid]);
- x += (player_dist * floatsin(-aPos[playerid], degrees));
- y += (player_dist * floatcos(-aPos[playerid], degrees));
- gData[TotalGrenades][GrenadeObj] = CreateObject(342, x, y, z+0.4, 0, 0, 96);
- gData[TotalGrenades][gPlayer] = playerid;
- GetPlayerPos(playerid, x, y, aPos[playerid]);
- GetPlayerFacingAngle(playerid, aPos[playerid]);
- x += (launch_dist * floatsin(-aPos[playerid], degrees));
- y += (launch_dist * floatcos(-aPos[playerid], degrees));
- MoveObject(gData[TotalGrenades][GrenadeObj], x, y, z+3, 20.00);
- }
- else
- {
- SendClientMessage(playerid,-1,"Wait before launching another grenade");
- }
- }
- }
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- stage[playerid] = 0;
- return 1;
- }
- IsPlayerAiming(playerid)
- {
- new anim = GetPlayerAnimationIndex(playerid);
- if (((anim >= 1160) && (anim <= 1163)) || (anim == 1167) || (anim == 1365) ||
- (anim == 1643) || (anim == 1453) || (anim == 220)) return 1;
- return 0;
- }
- public OnObjectMoved(objectid)
- {
- new Float:x, Float:y, Float:z;
- if(stage[gData[TotalGrenades][gPlayer]] == 1)
- {
- GetObjectPos(gData[TotalGrenades][GrenadeObj], x, y, z);
- CA_FindZ_For2DCoord(x,y,z);
- x += (grenade_dist * floatsin(-aPos[gData[TotalGrenades][gPlayer]], degrees));
- y += (grenade_dist * floatcos(-aPos[gData[TotalGrenades][gPlayer]], degrees));
- MoveObject(gData[TotalGrenades][GrenadeObj], x, y, z, 20.00);
- stage[gData[TotalGrenades][gPlayer]] = 2;
- }
- else if(stage[gData[TotalGrenades][gPlayer]] == 2)
- {
- GetObjectPos(gData[TotalGrenades][GrenadeObj], x, y, z);
- stage[gData[TotalGrenades][gPlayer]] = 0;
- DestroyObject(gData[TotalGrenades][GrenadeObj]);
- TotalGrenades--;
- CreateExplosion(x, y, z, 2, 10.0);
- }
- return 1;
- }
- CMD:test(playerid) return GivePlayerWeapon(playerid,31,100);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement