SA-MP Forums Archive
onplayershootplayer 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: onplayershootplayer problem (/showthread.php?tid=551462)



onplayershootplayer problem - 1fret - 19.12.2014

im making a cops and robbers but i have a small issue i made a code that if a player shoots a police they should get wanted and if a cop shoot an innocent player it send a message to the online admins and show a gametext
pawn Код:
forward OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost);
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)
{
    new issuerid;
    new targetid;
    if(issuerid != INVALID_PLAYER_ID && targetid != INVALID_PLAYER_ID)
    {
        if(GetPlayerTeam(targetid) == GetPlayerTeam(issuerid))
        {
            new Float:AttackerHP;
            GetPlayerHealth(issuerid, AttackerHP);
            SetPlayerHealth(issuerid, AttackerHP-5.0);
            GameTextForPlayer(issuerid, "~r~Thats your team mate, stop shooting ", 5000, 5);
        }
    }
    new shoter, shotted, shoterid, shottedid, srtin[128];
    if(gTeam[shoter] != TEAM_POLICE)
    {
        if(GetPlayerTeam(shotted) == TEAM_POLICE)
        {
            IncreaseWantedLevel(shoter,2);
            format(srtin,sizeof(srtin),"[POLICE RADIO] Suspect %s(%d) is wanted for shooting/murdering officer %s(%d) and is Harmed and Dangerours proceed with caution.",shoter,shoterid,shotted,shottedid);
            SendClientMessageToAllCops(srtin);
        }
    }
    new rshot, shot, rstring [128], rshotid,  rstring2 [128];
    if(gTeam[shot] == TEAM_POLICE)
    {
        if(GetPlayerWantedLevel(rshot) == 0)
        {
            format(rstring,sizeof(rstring),"%s(%d)'s is not a wanted player.",rshot,rshotid);
            SendClientMessage(shot,red,rstring);
            format(rstring2,sizeof(rstring2),"[AUTO DETECT] Officer %s(%d) is shooting a player thats not wanted",shot,shoterid);
            SendClientMessageToAllAdmins(rstring2);
        }
    }
    return 1;
}
Can someone tell me whats the problem in the code none of it work.


Re: onplayershootplayer problem - xCrazyMonkey - 19.12.2014

what's the result of the code you have now? Does it even do anything or absolutely nothing?


Re: onplayershootplayer problem - mahdi499 - 19.12.2014

If i may ask why are you defining new variables(issureid, targetid] while it's predefined in the callback (shooter,target)


Re: onplayershootplayer problem - 1fret - 20.12.2014

Quote:
Originally Posted by mahdi499
Посмотреть сообщение
If i may ask why are you defining new variables(issureid, targetid] while it's predefined in the callback (shooter,target)
pawn Код:
forward OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost);
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)
{
    new issuerid;
    new targetid;
    if(issuerid != INVALID_PLAYER_ID && targetid != INVALID_PLAYER_ID)
    {
        if(GetPlayerTeam(targetid) == GetPlayerTeam(issuerid))
        {
            new Float:AttackerHP;
            GetPlayerHealth(issuerid, AttackerHP);
            SetPlayerHealth(issuerid, AttackerHP-5.0);
            GameTextForPlayer(issuerid, "~r~Thats your team mate, stop shooting ", 5000, 5);
        }
    }
    new srtin[128];
    if(gTeam[issuerid] != TEAM_POLICE)
    {
        if(GetPlayerTeam(targetid) == TEAM_POLICE)
        {
            IncreaseWantedLevel(issuerid,2);
            format(srtin,sizeof(srtin),"[POLICE RADIO] Suspect %s is wanted for shooting/murdering officer %s and is Harmed and Dangerours proceed with caution.",issuerid,targetid);
            SendClientMessageToAllCops(srtin);
        }
    }
    new rstring2 [128],rstring [128];
    if(gTeam[issuerid] == TEAM_POLICE)
    {
        if(GetPlayerWantedLevel(targetid) == 0)
        {
            format(rstring,sizeof(rstring),"%s is not a wanted player.",targetid);
            SendClientMessage(issuerid,red,rstring);
            format(rstring2,sizeof(rstring2),"Officer %s is shooting a player thats not wanted",issuerid);
            SendClientMessageToAllAdmins(rstring2);
        }
    }
    return 1;
}
Changed them but still not working


Re: onplayershootplayer problem - 1fret - 20.12.2014

Bump


Re: onplayershootplayer problem - Ryz - 20.12.2014

try not sure don't fu*k me if not work

Change this

pawn Код:
new issuerid;
new targetid;
to this one

pawn Код:
new issuerid = Shooter;
new targetid = Target;