Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <foreach>
- #include <streamer>
- #include <colandreas>
- #define SNOW_BALL_SLOT 3
- new bool:snow_thrown[MAX_PLAYERS char] = {false,...};
- new snow_ball[MAX_PLAYERS] = {0,...};
- new Float:player_angle[MAX_PLAYERS] = {0.0,...};
- public OnFilterScriptInit()
- {
- CA_Init();
- return 1;
- }
- public OnFilterScriptExit()
- {
- foreach(new i : Player)
- {
- if(snow_ball[i] == 0) continue;
- RemovePlayerAttachedObject(i, SNOW_BALL_SLOT);
- DestroyDynamicObject(snow_ball[i]);
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.1, 0, 0, 0, 0, 1000, 0);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(snow_ball[playerid] != 0)
- {
- snow_thrown{playerid} = false;
- DestroyDynamicObject(snow_ball[playerid]);
- RemovePlayerAttachedObject(playerid, SNOW_BALL_SLOT);
- snow_ball[playerid] = 0;
- player_angle[playerid] = 0.0;
- }
- return 1;
- }
- Float:Speed(playerid)
- {
- new Float:x, Float:y, Float:z;
- GetPlayerVelocity(playerid, x, y, z);
- return ((x*x) + (y*y) + (z*z));
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- new Float:x, Float:y, Float:z, Float:a;
- if(newkeys & 65536)
- {
- if(!IsPlayerInAnyVehicle(playerid) && Speed(playerid) == 0.00 && snow_ball [playerid] == 0)
- {
- ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.1, 0, 0, 0, 0, 1000, 1);
- SetPlayerAttachedObject(playerid, SNOW_BALL_SLOT, 1974, 6, 0.05, 0.04, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
- snow_ball[playerid] = CreateDynamicObject(1974, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0);
- }
- }
- if(newkeys & 4)
- {
- if(!IsPlayerInAnyVehicle(playerid) && snow_ball[playerid] != 0 && !snow_thrown{playerid})
- {
- GetPlayerPos(playerid, x, y, z);
- GetPlayerFacingAngle(playerid, a);
- ApplyAnimation(playerid, "GRENADE", "WEAPON_throw", 4.1, 0, 0, 0, 0, 700, 1);
- RemovePlayerAttachedObject(playerid, SNOW_BALL_SLOT);
- SetDynamicObjectPos(snow_ball[playerid], x, y, z+1.50);
- player_angle[playerid] = a;
- x += 10.0 * floatsin(-a, degrees);
- y += 10.0 * floatcos(-a, degrees);
- MoveDynamicObject(snow_ball[playerid], x, y, z+7.0, 6.0);
- snow_thrown{playerid} = true;
- }
- }
- return 1;
- }
- public OnDynamicObjectMoved(objectid)
- {
- new Float:x, Float:y, Float:z, Float:z2;
- foreach(new i : Player)
- {
- if(objectid != snow_ball[i]) continue;
- GetDynamicObjectPos(objectid, x, y, z);
- CA_FindZ_For2DCoord(x, y, z2);
- if(z != z2)
- {
- x += 14.0 * floatsin(-player_angle[i], degrees);
- y += 14.0 * floatcos(-player_angle[i], degrees);
- MoveDynamicObject(snow_ball[i], x, y, z2, 6.8);
- break;
- }
- DestroyDynamicObject(snow_ball[i]);
- snow_ball[i] = 0;
- snow_thrown{i} = false;
- break;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement