Small /tazer bug +rep
#1

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?
Reply
#2

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;
}
Reply
#3

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
Reply
#4

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;
}
Reply
#5

Код:
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;
            }
        }
    }
}
Reply
#6

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.
Reply
#7

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

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.
Reply
#9

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)