SA-MP Forums Archive
/frisk :S - 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: /frisk :S (/showthread.php?tid=464306)



/frisk :S - Lajko1 - 16.09.2013

pawn Код:
CMD:frisk(playerid, params[])
{
    new
        id,
        Slot,
        Weapon,
        Ammo,
        CNT,
        X,
        Str[128],
        Str2[64],
        WN[32],
        Float:x,
        Float:y,
        Float:z,
        Name[MAX_PLAYER_NAME];

    GetPlayerName(id, Name, sizeof(Name));
    GetPlayerPos(id, x, y, z); // Your position

    if (sscanf(params, "u", id)) return SendClientMessage(playerid, 0xAA3333AA, "Usage: \"/frisk [playerid]\"");
    else if (!IsPlayerCop(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "You are not authorized to use this command");
    else if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "Invalid player ID");
    else if (IsPlayerInAnyVehicle(id)) return SendClientMessage(playerid, 0xFF0000AA, "That player is in vehicle");
    else if (!IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z)) return SendClientMessage(playerid, 0xFF0000AA, "You are not near that player");
    else if (id == playerid) return SendClientMessage(playerid, 0xFF0000AA,"You can't frisk yourself");
What is wrong with this command ? I'm testing it on server and it's says "You are not near that player" ... I was trying to edit IsPlayerInRangeOfPoint and remove "!" but I think this won't work.. what is wrong here ?
EDIT: I have rest of code under this.. but main problem is with this "You are not near that player"... as I said when I removed "!" it says weapons from ID 0 ...


Re: /frisk :S - EiresJason - 16.09.2013

What i think is wrong is that you are trying to get the players position before you actually set his information into 'id'. So basically x, y and z are all registered as '0.0'.

Try this;
pawn Код:
CMD:frisk(playerid, params[])
{
    new
        id,
        Slot,
        Weapon,
        Ammo,
        CNT,
        X,
        Str[128],
        Str2[64],
        WN[32],
        Float:x,
        Float:y,
        Float:z,
        Name[MAX_PLAYER_NAME];

    if (sscanf(params, "u", id)) return SendClientMessage(playerid, 0xAA3333AA, "Usage: \"/frisk [playerid]\"");
    GetPlayerName(id, Name, sizeof(Name));
    GetPlayerPos(id, x, y, z); // Your position
    if (!IsPlayerCop(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "You are not authorized to use this command");
    else if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "Invalid player ID");
    else if (IsPlayerInAnyVehicle(id)) return SendClientMessage(playerid, 0xFF0000AA, "That player is in vehicle");
    else if (!IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z)) return SendClientMessage(playerid, 0xFF0000AA, "You are not near that player");
    else if (id == playerid) return SendClientMessage(playerid, 0xFF0000AA,"You can't frisk yourself");



Re: /frisk :S - Lajko1 - 16.09.2013

WEll thanks for respond but it's still same... "You are not near that player",... any other help please ?

EDIT:
pawn Код:
CMD:frisk(playerid, params[])
{
    new
        id,
        Slot,
        Weapon,
        Ammo,
        CNT,
        X,
        Str[128],
        Str2[64],
        WN[32],
        Float:x,
        Float:y,
        Float:z,
        Name[MAX_PLAYER_NAME];

    if (sscanf(params, "u", id)) return SendClientMessage(playerid, 0xAA3333AA, "Usage: \"/frisk [playerid]\"");
    GetPlayerName(id, Name, sizeof(Name));
    GetPlayerPos(id, x, y, z); // Your position
    if (!IsPlayerCop(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "You are not authorized to use this command");
    else if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "Invalid player ID");
    else if (IsPlayerInAnyVehicle(id)) return SendClientMessage(playerid, 0xFF0000AA, "That player is in vehicle");
    else if (!IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z)) return SendClientMessage(playerid, 0xFF0000AA, "You are not near that player");
    else if (id == playerid) return SendClientMessage(playerid, 0xFF0000AA,"You can't frisk yourself");
    else
    {
    format(Str2, sizeof(Str2), "__________%s's Weapon Information___________", Name);
    SendClientMessage(playerid, COLOR_YELLOW, Str2);
    for(Slot = 0; Slot < 14; Slot++)
    {
        GetPlayerWeaponData(id, Slot, Weapon, Ammo);
        if( Ammo != 0 && Weapon != 0)
        CNT++;
    }
    if(CNT < 1) return SendClientMessage(playerid,0x33AA33AA,"No weapons found!");
    if(CNT >= 1)
    {
        for (Slot = 0; Slot < 14; Slot++)
        {
            GetPlayerWeaponData(id, Slot, Weapon, Ammo);
            if( Ammo != 0 && Weapon != 0)
            {
                GetWeaponName(Weapon,WN, sizeof(WN));
                if(Ammo == 65535 || Ammo == 1)
                format(Str,sizeof(Str),"%s%s (1)",Str, WN);
                else format(Str,sizeof(Str),"%s%s (%d)",Str, WN, Ammo);
                X++;
                if(X >= 5)
                {
                    SendClientMessage(playerid, 0x33AA33AA, Str);
                    X = 0;
                    format(Str, sizeof(Str), "");
                }
                else format(Str, sizeof(Str), "%s,  ", Str);
                }
            }
        if(X <= 4 && X > 0)
        {
            Str[strlen(Str)-3] = '.';
            SendClientMessage(playerid, 0x33AA33AA, Str);
            }
        }
    }
    return 1;
}
Well here is my whole command, when I'm testing it on 1 server it says "You are not near that player"
If I remove "!" from IsPlayerInRange bla bla... It is automatic checking ID:0, help please and thanks in advance


Re: /frisk :S - EiresJason - 16.09.2013

You are definitely standing beside the player right?
I just threw the CMD into my script to test it and it worked like this;
pawn Код:
CMD:frisk(playerid, params[])
{
    if (!IsCop[playerid]) return SendClientMessage(playerid, 0xFF0000AA, "You are not authorized to use this command");
    new
        id,
        Slot,
        Weapon,
        Ammo,
        CNT,
        X,
        Str[128],
        Str2[64],
        WN[32],
        Float:x,
        Float:y,
        Float:z,
        Name[MAX_PLAYER_NAME];

    if (sscanf(params, "u", id)) return SendClientMessage(playerid, 0xAA3333AA, "Usage: \"/frisk [playerid]\"");
    GetPlayerName(id, Name, sizeof(Name));
    GetPlayerPos(id, x, y, z); // Your position
    printf("XIS:%f YIS:%f ZIS:%f", x,y,z);
    if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "Invalid player ID");
    else if (IsPlayerInAnyVehicle(id)) return SendClientMessage(playerid, 0xFF0000AA, "That player is in vehicle");
    else if (!IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z)) return SendClientMessage(playerid, 0xFF0000AA, "You are not near that player");
    else if (id == playerid) return SendClientMessage(playerid, 0xFF0000AA,"You can't frisk yourself");
    else
    {
    format(Str2, sizeof(Str2), "__________%s's Weapon Information___________", Name);
    SendClientMessage(playerid, COLOR_YELLOW, Str2);
    for(Slot = 0; Slot < 14; Slot++)
    {
        GetPlayerWeaponData(id, Slot, Weapon, Ammo);
        if( Ammo != 0 && Weapon != 0)
        CNT++;
    }
    if(CNT < 1) return SendClientMessage(playerid,0x33AA33AA,"No weapons found!");
    if(CNT >= 1)
    {
        for (Slot = 0; Slot < 14; Slot++)
        {
            GetPlayerWeaponData(id, Slot, Weapon, Ammo);
            if( Ammo != 0 && Weapon != 0)
            {
                GetWeaponName(Weapon,WN, sizeof(WN));
                if(Ammo == 65535 || Ammo == 1)
                format(Str,sizeof(Str),"%s%s (1)",Str, WN);
                else format(Str,sizeof(Str),"%s%s (%d)",Str, WN, Ammo);
                X++;
                if(X >= 5)
                {
                    SendClientMessage(playerid, 0x33AA33AA, Str);
                    X = 0;
                    format(Str, sizeof(Str), "");
                }
                else format(Str, sizeof(Str), "%s,  ", Str);
                }
            }
        if(X <= 4 && X > 0)
        {
            Str[strlen(Str)-3] = '.';
            SendClientMessage(playerid, 0x33AA33AA, Str);
            }
        }
    }
    return 1;
}
Stand right beside the player and test it. Also; remove
pawn Код:
printf("XIS:%f YIS:%f ZIS:%f", x,y,z);
if you want; i just used it to debug.

Incase you don't know; the 5.0 in this line;
pawn Код:
(!IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z))
is the distance from you to point of x,y,z.


Re: /frisk :S - Lajko1 - 16.09.2013

Okay, I tested it on my own Testing server and every thing works wonderful there, but when I send that command to friend and when we are on his server it write "You are not near that player" :S when I port to ID 0 - Bot it works good, why is my command working only for ID 0 and nobody else ?
I have if player don't write ID it will send him error message how to use this command.. but when I write only /frisk without ID it's automatic says to me "You are not near that player" when I port to ID 0, then command work ..

Is possible that I need to put this somewhere in my code ?
for(new i; i<MAX_PLAYERS; i++)
{

If yes.. Where ? Thanks for responses and help ^^


Re: /frisk :S - EiresJason - 16.09.2013

Well; it says "You are not near that player" if you type /frisk without the ID because it isn't getting the position of anyone so X/Y/Z will be 0.0.

It should all work properly if you enter in an ID to frisk.

I just tested it on mine and it works perfectly.

If i type '/frisk'; i get the 'USAGE: /frisk [playerid]' message.
If i type 'frisk [playerid]' and I am near the player; it will frisk them.

You don't need any loop in your code as you are only frisking the person you specify.

You are standing beside the player though right? Like you need to be really close to the player to frisk them. Basically within arms reach of them for the command to work.

(I wont be able to reply again for like 2hours or something as I have to go out, but i will help when i get back)

Maybe get him to place the frisk command at the very bottom of his script and try again, and to have all the latest versions of the includes like sscanf2, etc.


Re: /frisk :S - Lajko1 - 16.09.2013

Well as I said on my test server this command works great, but when I'm testing it on friend's server there is always same thing now matter what I do in code, "You are not near that player"...
So problem here is it only work for ID 0, cuz if I port to BOT that is ID 0, then it frisk him, but it don't work for nobody else
So current problems are:
-When I type only /frisk it says "You are not near that player" without error message that is supposed to be "Usage:/frisk [playerid]"
-Command works only if I'm near ID 0 without writing /frisk 0, it will frisk him..
-If I write /frisk (any other ID) it will say "You are not near that player"..

I just can't figure out what is wrong here...


Re: /frisk :S - Patrick - 16.09.2013

I guess I found the problem

Instead of this
pawn Код:
else if (!IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z)) return SendClientMessage(playerid, 0xFF0000AA, "You are not near that player");
Use this
pawn Код:
else if (IsPlayerInRangeOfPoint(id, 5.0, x, y, z)) return SendClientMessage(playerid, 0xFF0000AA, "You are not near that player");
when you execute the command, it checks your x,y,z not the player's x,y,z, I hope this helps you


Re: /frisk :S - xganyx - 16.09.2013

Test this

pawn Код:
#include <a_samp>
#include <sscanf2>
#include <zcmd>

CMD:frisk(playerid, params[])
{
    new
        id,
        Slot,
        Weapon,
        Ammo,
        CNT,
        X,
        Str[128],
        Str2[64],
        WN[32],
        Float:x,
        Float:y,
        Float:z,
        Name[MAX_PLAYER_NAME];

    if (sscanf(params, "u", id)) return SendClientMessage(playerid, 0xAA3333AA, "Usage: \"/frisk [playerid]\"");
    GetPlayerName(id, Name, sizeof(Name));
    GetPlayerPos(id, x, y, z);
    if (!IsPlayerCop(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "You are not authorized to use this command");
    if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "Invalid player ID");
    if (IsPlayerInAnyVehicle(id)) return SendClientMessage(playerid, 0xFF0000AA, "That player is in vehicle");
    if (id == playerid) return SendClientMessage(playerid, 0xFF0000AA,"You can't frisk yourself");
    if (!IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z)) return SendClientMessage(playerid, 0xFF0000AA, "You are not near that player");
    format(Str2, sizeof(Str2), "__________%s's Weapon Information___________", Name);
    SendClientMessage(playerid, COLOR_YELLOW, Str2);
    for(Slot = 0; Slot < 14; Slot++)
    {
        GetPlayerWeaponData(id, Slot, Weapon, Ammo);
        if( Ammo != 0 && Weapon != 0)
        CNT++;
    }
    if(CNT < 1) return SendClientMessage(playerid,0x33AA33AA,"No weapons found!");
    if(CNT >= 1)
    {
        for (Slot = 0; Slot < 14; Slot++)
        {
            GetPlayerWeaponData(id, Slot, Weapon, Ammo);
            if( Ammo != 0 && Weapon != 0)
            {
                GetWeaponName(Weapon,WN, sizeof(WN));
                if(Ammo == 65535 || Ammo == 1)
                format(Str,sizeof(Str),"%s%s (1)",Str, WN);
                else format(Str,sizeof(Str),"%s%s (%d)",Str, WN, Ammo);
                X++;
                if(X >= 5)
                {
                    SendClientMessage(playerid, 0x33AA33AA, Str);
                    X = 0;
                    format(Str, sizeof(Str), "");
                }
                else format(Str, sizeof(Str), "%s,  ", Str);
            }
            if(X <= 4 && X > 0)
            {
                Str[strlen(Str)-3] = '.';
                SendClientMessage(playerid, 0x33AA33AA, Str);
            }
        }
    }
    return 1;
}



Re: /frisk :S - Lajko1 - 16.09.2013

Well thanks for response but it don't work :/