SA-MP Forums Archive
OnPlayerWeaponShot..... - 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..... (/showthread.php?tid=527612)



OnPlayerWeaponShot..... - danish007 - 23.07.2014

Hello, i've made a shooting gun in public.

its not working when players shots. please check this?

PHP код:
public OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
    new 
string[256];
    if(
PlayerInfo[playerid][pSpawn] == && PlayerInfo[playerid][pShootingTime] <= && PlayerInfo[playerid][pJailed] == && PlayerInfo[playerid][pAJailed] == 0)
       {
       if(
PlayerInfo[playerid][pTeam] != TEAM_LAW && PlayerInfo[playerid][pVigilante] == 0)
    {
    if(
IsSuspectInRangeOfPolice1(playerid) && !IsPlayerInAnyVehicle(playerid))
    {
    if(
PlayerInfo[playerid][pWantedLevel] >= 6)PlayerInfo[playerid][pWantedLevel]++;else PlayerInfo[playerid][pWantedLevel] =6;
    
SetPlayerWantedStats(playerid,"Shooting Gun In Public");
    
format(stringsizeof(string), "Crime: Shooting Gun In Public");
    
ReportCrimeTOPolice(playerid,string);
    
PlayerInfo[playerid][pShootingTime] =20;
    }
    }
    }
    return 
1;




Re: OnPlayerWeaponShot..... - Mauzen - 23.07.2014

if(PlayerInfo[playerid][pWantedLevel] >= 6)

This one is wrong here, you dont want to check if the players wanted level is bigger that 6, but if it is smaller

if(PlayerInfo[playerid][pWantedLevel] < 6)


Re: OnPlayerWeaponShot..... - danish007 - 23.07.2014

its right. if player wanted is more than 6 wanted level increase one by one and if less than 6 wanted level direct to 6.

function is not working why? when i shoot near cop even msgs are not showing


Re: OnPlayerWeaponShot..... - danish007 - 23.07.2014

anyone please?


Re: OnPlayerWeaponShot..... - Ihateyou - 23.07.2014

where is timer to decrease pShootingTime?


Re: OnPlayerWeaponShot..... - Virtual1ty - 23.07.2014

It's hard to say considering we don't know what many of those variables in the "if" check evaluate to. One of them must be faulty when the code doesn't pass to desired actions, SetPlayerWanted..etc.
Try loosing one by one variable/function from the "if" check to narrow down the cause, I hardly think it's the public's fault.
I would bet on the range check because that's the one we have least information on.
Good luck debugging! Also, for the love of God, INDENT your future code, imagine how much we have had to struggle reading that, and me trying to optimise your GM.
Best of luck!

Edit: the solution is to enable 'lagcompmode' in the server.cfg as this was introduced in 0.3z.