16.06.2012, 16:28
Include has two functions:
- GivePlayerSpecialWeapon (playerid, ammo)
Give a special weapon ammo to playerid with X
- ResetPlayerSpecialWeapon (playerid)
Remove the weapon's special playerid
The special weapon is a missile launcher chasing the target, if no target, the missile straight dry according to where you are looking: p The missile launcher weapon and represented by SPAZ, and ativa-lб/desativa-lб (if you have a special weapon) just press Y to shoot the missile and the weapon automatically switches to SPAZ normal and after 5 seconds automatically returns to the missile launcher. The missile chasing the target for 5 seconds, after which it explodes, the same goes if you have no target.
Video:
[ame]http://www.youtube.com/watch?v=t2oyX9GoUXo[/ame]
Download:
Testing and 100 percent functional credit me and the end of the video information on it, without permission to post elsewhere!
I hope you enjoy it and comment!
Original Topic:
http://forum.sa-mp.com/showthread.ph...02#post1927302
- GivePlayerSpecialWeapon (playerid, ammo)
Give a special weapon ammo to playerid with X
- ResetPlayerSpecialWeapon (playerid)
Remove the weapon's special playerid
The special weapon is a missile launcher chasing the target, if no target, the missile straight dry according to where you are looking: p The missile launcher weapon and represented by SPAZ, and ativa-lб/desativa-lб (if you have a special weapon) just press Y to shoot the missile and the weapon automatically switches to SPAZ normal and after 5 seconds automatically returns to the missile launcher. The missile chasing the target for 5 seconds, after which it explodes, the same goes if you have no target.
Video:
[ame]http://www.youtube.com/watch?v=t2oyX9GoUXo[/ame]
Download:
pawn Код:
#include <a_samp>
#define KEY_AIM 128
new Missel[MAX_OBJECTS], m;
enum WeaponInfo
{
Ammo1,
Ammo2,
bool:Have,
bool:Lauch,
Timer,
bool:Wating
}
new WI[MAX_PLAYERS][WeaponInfo];
// Filter by Gustavo Bonomo
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_YES && GetPlayerWeapon(playerid) == 27 && WI[playerid][Have] == true && WI[playerid][Wating] == false)
{
if(WI[playerid][Lauch] == false)
{
new ammo, weapon;
GetPlayerWeaponData(playerid, 3, weapon, ammo);
WI[playerid][Ammo2] = ammo;
RemovePlayerWeapon(playerid, 27);
WI[playerid][Lauch] = true;
GivePlayerWeapon(playerid, 27, WI[playerid][Ammo1]);
GameTextForPlayer(playerid, "ON", 1000, 4);
ApplyAnimation(playerid, "UZI", "UZI_reload", 4.1, 0, 1, 1, 1, 1, 1);
}
else
{
RemovePlayerWeapon(playerid, 27);
WI[playerid][Lauch] = false;
GivePlayerWeapon(playerid, 27, WI[playerid][Ammo2]);
GameTextForPlayer(playerid, "OFF", 1000, 4);
ApplyAnimation(playerid, "UZI", "UZI_reload", 4.1, 0, 1, 1, 1, 1, 1);
}
}
else if((newkeys & KEY_FIRE && newkeys & KEY_AIM || newkeys == KEY_FIRE) && GetPlayerWeapon(playerid) == 27 && WI[playerid][Have] == true && WI[playerid][Lauch] == true && WI[playerid][Wating] == false)
{
new target = GetPlayerTargetPlayer(playerid);
LancarMissel(playerid, target);
RemovePlayerWeapon(playerid, 27);
WI[playerid][Wating] = true;
WI[playerid][Ammo1] --;
GivePlayerWeapon(playerid, 27, WI[playerid][Ammo2]);
GameTextForPlayer(playerid, "OFF", 1000, 4);
ApplyAnimation(playerid, "UZI", "UZI_reload", 4.1, 0, 1, 1, 1, 1, 1);
SetTimerEx("Liberar", 5000, false, "i", playerid);
}
return 1;
}
#if defined _ALS_OnPlayerKeyStateChange
#undef OnPlayerKeyStateChange
#else
#define _ALS_OnPlayerKeyStateChange
#endif
#define OnPlayerKeyStateChange gb_OnPlayerKeyStateChange
forward gb_OnPlayerKeyStateChange();
forward Liberar(playerid);
public Liberar(playerid)
{
RemovePlayerWeapon(playerid, 27);
WI[playerid][Wating] = false;
GivePlayerWeapon(playerid, 27, WI[playerid][Ammo1]);
GameTextForPlayer(playerid, "ON", 1000, 4);
ApplyAnimation(playerid, "UZI", "UZI_reload", 4.1, 0, 1, 1, 1, 1, 1);
return 1;
}
forward AtualizarMissel(playerid, objid);
public AtualizarMissel(playerid, objid)
{
new Float:PosT[3];
GetPlayerPos(playerid, PosT[0], PosT[1], PosT[2]);
if(ObjectToPoint(2.0, objid, PosT[0], PosT[1], PosT[2]))
{
CreateExplosion(PosT[0], PosT[1], PosT[2], 5, 10.0);
DestroyObject(objid);
KillTimer(WI[playerid][Timer]);
}
else if(PosT[0] != GetPVarFloat(playerid, "playerX") || PosT[1] != GetPVarFloat(playerid, "playerY") || PosT[2] != GetPVarFloat(playerid, "playerZ"))
{
SetPVarFloat(playerid, "playerX", PosT[0]), SetPVarFloat(playerid, "playerY", PosT[1]), SetPVarFloat(playerid, "playerZ", PosT[2]);
StopObject(objid);
MoveObject(objid, PosT[0], PosT[1], PosT[2], 10.0);
}
return 1;
}
forward FinalizarMissel(objid);
public FinalizarMissel(objid)
{
new Float:Pos[3];
GetObjectPos(objid, Pos[0], Pos[1], Pos[2]);
CreateExplosion(Pos[0], Pos[1], Pos[2], 5, 10.0);
DestroyObject(objid);
return 1;
}
stock LancarMissel(playerid, target)
{
m++;
new Float:PosT[3], Float:PosP[3];
GetPlayerPos(playerid, PosP[0], PosP[1], PosP[2]);
if(target != INVALID_PLAYER_ID)
{
GetPlayerPos(target, PosT[0], PosT[1], PosT[2]);
Missel[m] = CreateObject(354, PosP[0], PosP[1], PosP[2], 0.0, 0.0, 0.0);
MoveObject(Missel[m], PosT[0], PosT[1], PosT[2], 10.0);
SetPVarFloat(playerid, "playerX", PosT[0]), SetPVarFloat(playerid, "playerY", PosT[1]), SetPVarFloat(playerid, "playerZ", PosT[2]);
WI[playerid][Timer] = SetTimerEx("AtualizarMissel", 250, true, "ii", target, Missel[m]);
SetTimerEx("FinalizarMissel", 5000, false, "i", Missel[m]);
}
else
{
new Float:fP[3], Float:fV[3], Float:PosO[3];
GetPlayerCameraPos(playerid, fP[0], fP[1], fP[2]);
GetPlayerCameraFrontVector(playerid, fV[0], fV[1], fV[2]);
PosO[0] = fP[0] + floatmul(fV[0], 60.0);
PosO[1] = fP[1] + floatmul(fV[1], 60.0);
PosO[2] = fP[2] + floatmul(fV[2], 60.0);
Missel[m] = CreateObject(354, PosP[0], PosP[1], PosP[2], 0.0, 0.0, 0.0);
MoveObject(Missel[m], PosO[0], PosO[1], PosO[2], 10.0);
SetTimerEx("FinalizarMissel", 5000, false, "i", Missel[m]);
}
return 1;
}
stock RemovePlayerWeapon(playerid, weaponid)
{
if(!IsPlayerConnected(playerid) || weaponid < 0 || weaponid > 50)
return;
new
saveweapon[13],
saveammo[13];
for(new slot = 0; slot < 13; slot++)
GetPlayerWeaponData(playerid, slot, saveweapon[slot], saveammo[slot]);
ResetPlayerWeapons(playerid);
for(new slot; slot < 13; slot++)
{
if(saveweapon[slot] == weaponid || saveammo[slot] == 0)
continue;
GivePlayerWeapon(playerid, saveweapon[slot], saveammo[slot]);
}
GivePlayerWeapon(playerid, 0, 1);
}
stock ObjectToPoint(Float:radi, objectid, Float:x, Float:y, Float:z)
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetObjectPos(objectid, oldposx, oldposy, oldposz);
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
return 0;
}
stock GivePlayerSpecialWeapon(playerid, ammu)
{
WI[playerid][Have] = true;
WI[playerid][Ammo1] = ammu;
new ammo, weapon;
GetPlayerWeaponData(playerid, 3, weapon, ammo);
WI[playerid][Ammo2] = ammo;
RemovePlayerWeapon(playerid, 27);
GivePlayerWeapon(playerid, 27, WI[playerid][Ammo1]);
return 1;
}
stock ResetPlayerSpecialWeapon(playerid)
{
Have[playerid] = false;
Lauch[playerid] = false;
Ammo[playerid] = 0;
RemovePlayerWeapon(playerid, 27);
return 1;
}
I hope you enjoy it and comment!
Original Topic:
http://forum.sa-mp.com/showthread.ph...02#post1927302