OnPlayerWeaponShot problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnPlayerWeaponShot problem (
/showthread.php?tid=515597)
OnPlayerWeaponShot problem -
Gecko75 - 26.05.2014
Hi- I made a small script where when you shoot a spot on the ground, or even shoot a player.. It's supposed to TP you to the spot you shot, OR 'slap' the player you shot into the air.
The problem is, the fX fY and fZ are returning 0.0 as a float value, even though I'm shooting something.
I even set up a little script to show me what I'm shooting, and it still doesn't return a float variable for any of the float values.
Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
new Float:origin[3];
new Float:hitloc[3];
//GetPlayerLastShotVectors(playerid, origin[0], origin[1], origin[2], hitloc[0], hitloc[1], hitloc[2]);
if(RIPrifle[playerid] != 0)
{
if(weaponid == 33)
{
if(hittype == BULLET_HIT_TYPE_NONE)
{
if(RIPrifle[playerid] == 1)
{
SetPlayerPos(playerid, fX, fY, fZ);
SCM(playerid, COLOR_LIGHTRED, "You shot the RIP rifle and teleported! HACKSS!!!!!!!!");
}
if(RIPrifle[playerid] == 2)
{
CreateExplosion(fX, fY, fZ, 0, 10.0);
}
}
if(hittype == BULLET_HIT_TYPE_PLAYER)
{
if(hitid != INVALID_PLAYER_ID)
{
if(RIPrifle[playerid] == 3)
{
format(msg,sizeof(msg),"* The RIP Rifle bullet flies towards %s, and hits them in the ass.", GetName(hitid));
SCMALL(COLOR_PURPLE, msg);
Kick(hitid);
}
if(RIPrifle[playerid] == 6)
{
SetPlayerPos(hitid, fX, fY, fZ+75);
}
}
}
if(hittype == BULLET_HIT_TYPE_VEHICLE)
{
if(hitid != INVALID_VEHICLE_ID)
{
if(RIPrifle[playerid] == 5)
{
new col1 = randomEx(1, 157);
new col2 = randomEx(1, 157);
ChangeVehicleColor(hitid, col1, col2);
}
if(RIPrifle[playerid] == 6)
{
SetVehicleVelocity(hitid, 100.0, 0.0, 0.0);
}
}
}
}
}
format(msg, sizeof(msg), "Weapon %i fired. hittype: %i hitid: %i pos: %f, %f, %f", weaponid, hittype, hitid, fX, fY, fZ);
DebugMSG(playerid, msg);
return 1;
}
You can see here, after reviewing the small little script I set up- I shot the ground many times, and it's still returning 0.0.
Re: OnPlayerWeaponShot problem -
Lynn - 27.05.2014
Use
BULLET_HIT_TYPE_OBJECT
instead of;
BULLET_HIT_TYPE_NONE
This ^ means you hit nothing(Bullet went into thin air, not striking anything in it's path.)