SA-MP Forums Archive
Small /tazer bug +rep - 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: Small /tazer bug +rep (/showthread.php?tid=383734)



Small /tazer bug +rep - RLGaming - 08.10.2012

Code:
Quote:

if(newkeys & KEY_FIRE)
{
new string[128], giveplayerid;
if(GotTazer[playerid] == 1 && arrFaction[playerid][p_iMember] > 0)
{
if(IsPlayerConnected(giveplayerid))
{
if(ProxDetectorS(3.0, playerid,giveplayerid))
{
if(giveplayerid == playerid)
{
SendClientMessage(playerid, COLOR_WHITE, "You cannot stun yourself, you must get closer to your victim!");
}
TogglePlayerControllable(giveplayerid, 0);
format(string, sizeof(string), "*%s stuns %s with the tazer.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
return 1;
}
}
}
}

Whenever I go up to a player and do it, it just freezes me and says I have froze myself, any help on this?


Re : Small /tazer bug +rep - lelemaster - 08.10.2012

This post is my post in an other topic. I just recopied what I did.

Use OnPlayerGiveDamage
https://sampwiki.blast.hk/wiki/OnPlayerGiveDamage
playerid = cop
damageid = tazed man
weaponid = tazer id


Something like this:
pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
        if(GotTazer[playerid] == 1 && arrFaction[playerid][p_iMember] > 0)
        {
        TogglePlayerControllable(giveplayerid, 0);
                format(string, sizeof(string), "*%s stuns %s with the tazer.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
                ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
        }
        return 1;
}



Re: Small /tazer bug +rep - RLGaming - 08.10.2012

Im using the 0.3e tazer, i think its 0.3e or 0.3d tazer, the one that sits in your hand, it sets an object to my skin:
Quote:

SetPlayerAttachedObject(playerid, 0, 18642, 6, 0.06, 0.01, 0.08, 180.0, 0.0, 0.0);

So it isnt an atchual weapon


Re: Small /tazer bug +rep - Riddick94 - 08.10.2012

pawn Код:
if(giveplayerid == playerid)
{
SendClientMessage(playerid, COLOR_WHITE, "You cannot stun yourself, you must get closer to your victim!");
}
replace with:

pawn Код:
if(giveplayerid == playerid)
{
SendClientMessage(playerid, COLOR_WHITE, "You cannot stun yourself, you must get closer to your victim!");
return true;
}



Re: Small /tazer bug +rep - Skillet` - 08.10.2012

Код:
if(newkeys & KEY_FIRE)
{
    if(GotTazer[playerid] == 1 && arrFaction[playerid][p_iMember] > 0)
    {
        new Float:x,Float:y,Float:z,giveplayerid,bool:result = false,i = -1;
        GetPlayerPos(playerid,x,y,z);
        while(i < MAX_PLAYERS)
        {
            i++;
            if(IsPlayerInRangeOfPoint(i,3.0,x,y,z)
            {
                giveplayerid = i;
                result = true;
            }
        }
        if(result == true)
        {
            if(ProxDetectorS(3.0, playerid,giveplayerid))
            {
                if(giveplayerid == playerid) return SendClientMessage(playerid, COLOR_WHITE, "You cannot stun yourself, you must get closer to your victim!");
                new string[128];
                TogglePlayerControllable(giveplayerid, 0);
                format(string, sizeof(string), "*%s stuns %s with the tazer.", GetPlayerNameEx(playerid),GetPlayerNameEx(giveplayerid));
                ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
                result = false;
                return 1;
            }
        }
    }
}



Re : Re: Small /tazer bug +rep - lelemaster - 08.10.2012

The codes of Skillet are pretty good but need modification:

Код:
if(newkeys & KEY_FIRE)
{
    if(GotTazer[playerid] == 1 && arrFaction[playerid][p_iMember] > 0)
    {
        new Float:x,Float:y,Float:z,giveplayerid,bool:result = false,i = -1;
        GetPlayerPos(playerid,x,y,z);
        while(i < MAX_PLAYERS)
        {
            i++;
            if(IsPlayerInRangeOfPoint(i,3.0,x,y,z) && i != playerid) //You were missing a closing )
            {
                giveplayerid = i;
                result = true;
                break;
            }
        }
        if(result == true)
        {
            if(ProxDetectorS(3.0, playerid,giveplayerid))
            {
                new string[128];
                TogglePlayerControllable(giveplayerid, 0);
                format(string, sizeof(string), "*%s stuns %s with the tazer.", GetPlayerNameEx(playerid),GetPlayerNameEx(giveplayerid));
                ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
                result = false;
                return 1;
            }
        }
        else return SendClientMessage(playerid, COLOR_WHITE, "No one is near you!");
    }
}
It's better where I placed i != playerid, because in the codes of Skillet, the result will always be playerid if he has a lower id then the victim.


Re: Re : Re: Small /tazer bug +rep - Skillet` - 08.10.2012

Oh,didn't notice.
thanks for fixing me ...
btw
Код:
        else return SendClientMessage(playerid, COLOR_WHITE, "No one is near you!");
this may cause spam.


Re : Re: Re : Re: Small /tazer bug +rep - lelemaster - 08.10.2012

Quote:
Originally Posted by Skillet`
Посмотреть сообщение
Oh,didn't notice.
thanks for fixing me ...
btw
Код:
        else return SendClientMessage(playerid, COLOR_WHITE, "No one is near you!");
this may cause spam.
No, this wont, because if it doesn't find anyone after its loop, it will return the message, it's not returning every time it doesn't find a player.


Re: Re : Re: Re : Re: Small /tazer bug +rep - Skillet` - 08.10.2012

Quote:
Originally Posted by lelemaster
Посмотреть сообщение
No, this wont, because if it doesn't find anyone after its loop, it will return the message, it's not returning every time it doesn't find a player.
Yes,but it was not my point,my point was that the user can spam clicks.