Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- new FireShot[MAX_PLAYERS];
- new gKnifeObj[MAX_PLAYERS];
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/knife", cmdtext, true, 6) == 0)
- {
- GivePlayerWeapon(playerid, 4, 1);
- }
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(GetPlayerWeapon(playerid) == 4 && FireShot[playerid] == 0 && (newkeys & KEY_AIM) && !IsValidObject(gKnifeObj[playerid]))
- {
- ApplyAnimation(playerid,"GRENADE","WEAPON_throw",4.1,0,0,0,1,1,1);
- ApplyAnimation(playerid,"GRENADE","WEAPON_throw",4.1,0,0,0,1,1,1);
- new
- Float:x,
- Float:y,
- Float:z,
- Float:r,
- Float:HP,
- Float:dist = 50.0,
- Float:tmpang,
- Float:tmpx,
- Float:tmpy,
- Float:tmpz;
- FireShot[playerid] = 1;
- SetTimerEx("ShotFire", 1000, 0, "i", playerid);
- GetPlayerPos(playerid, x, y, z);
- GetPlayerFacingAngle(playerid, r);
- gKnifeObj[playerid] = CreateObject(335, x, y, z+0.7, -90, 0, r);
- for(new i;i<MAX_PLAYERS;i++)
- {
- if(i == playerid)continue;
- if(IsPlayerInRangeOfPoint(i, 50.0, x, y, z))
- {
- GetPlayerPos(i, tmpx, tmpy, tmpz);
- tmpang = (90-atan2(tmpy-y, tmpx-x));
- if(tmpang < 0)tmpang = 360.0+tmpang;
- tmpang = 360.0 - tmpang;
- if(floatabs(tmpang-r) < 5.0)
- {
- dist = GetPlayerDistanceFromPoint(i, x, y, z);
- GetPlayerHealth(i, HP);
- SetPlayerHealth(i, HP-35);
- }
- }
- }
- MoveObject(gKnifeObj[playerid],x + (dist * floatsin(-r, degrees)),y + (dist * floatcos(-r, degrees)),z,20); // Nice and fast!
- }
- return 1
- }
- forward ShotFire(playerid);
- public ShotFire(playerid)
- {
- FireShot[playerid] = 0;
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- for(new i;i<MAX_PLAYERS;i++)
- {
- if(objectid == gKnifeObj[i])
- {
- new
- Float:x,
- Float:y,
- Float:z;
- GetObjectPos(gKnifeObj[i], x, y, z);
- DestroyObject(gKnifeObj[i]);
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement