SA-MP Forums Archive
Impossible! - 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: Impossible! (/showthread.php?tid=472923)



Impossible! - Lajko1 - 31.10.2013

Guys this is so impossible for me I'm trying wasting hours for this but I can't make it work
What I want to make is to add few things if player is in car he can't use command, if other player is in car he can't use this command on him, if he is not in rage of player he can't perform this action on him, but in my command I get only 2 messages "you are not a cop" and "invalid player id" ANYTHING else I added nothing is working, why the hell? I commented a line also which is not working... and everything else I added but I deleted it wasn't working :/

pawn Код:
if(strcmp(cmd, "/frisk", true) == 0)
    {
        if(IsPlayerCop(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "Usage: /frisk [PlayerID]");
            new otherplayer = strval(tmp); // giveplayerid
            new Count, x; // warning line
            new string[128], string2[64];
            new WeapName[24], slot, weap, ammo;
            if(IsPlayerConnected(otherplayer) && otherplayer != INVALID_PLAYER_ID)
            {
                if(otherplayer == playerid) // THIS is not working
                {
                    format(string2,sizeof(string2),"_______|- %s's Weapons -|_______", otherplayer);
                    SendClientMessage(playerid,COLOR_LIGHTGREEN,string2);
                    for(slot = 0; slot < 14; slot++)
                    {
                    GetPlayerWeaponData(otherplayer, slot, weap, ammo);
                    if( ammo != 0 && weap != 0)
                    Count++;
                    }
                    if(Count < 1)
                    return SendClientMessage(playerid,COLOR_LIGHTGREEN,"No Weapons found!");
                    if(Count >= 1)
                    {
                        for (slot = 0; slot < 14; slot++)
                        {
                        GetPlayerWeaponData(otherplayer, slot, weap, ammo);
                        if( ammo != 0 && weap != 0)
                        {
                        GetWeaponName(weap, WeapName, sizeof(WeapName));
                        if(ammo == 65535 || ammo == 1)
                        format(string,sizeof(string),"%s%s (1)",string, WeapName);
                        else format(string,sizeof(string),"%s%s (%d)",string, WeapName, ammo);
                        x++;
                        if(x >= 5)
                        {
                        SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
                        x = 0;
                        format(string, sizeof(string), "");
                        }
                        else format(string, sizeof(string), "%s,  ", string);
                        }
                        }
                        if(x <= 4 && x > 0)
                        {
                        string[strlen(string)-3] = '.';
                        SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
                        }
                    }
                    return 1;
                }
                else return SendClientMessage(playerid,COLOR_LIGHTGREEN,"You can't frisk yourself!");
            }
            else return SendClientMessage(playerid,COLOR_LIGHTGREEN,"Invalid player ID!");
        }
        else return SendClientMessage(playerid,COLOR_LIGHTGREEN,"You are not cop!");
    }
    return 0;
}



Re: Impossible! - Jefff - 31.10.2013

if(otherplayer != playerid) not ==


Re: Impossible! - coool - 31.10.2013

Change
Код:
if(otherplayer == playerid)
To
Код:
if(otherplayer == playerid && != INVALID_PLAYER_ID)
And for in range of player you need to get target's pos and use
Код:
IsPlayerInRangeOfPoint
function.


Re: Impossible! - Lajko1 - 31.10.2013

Well thank you now this is working I will try to add more things to command


Re: Impossible! - Jefff - 31.10.2013

Try this

pawn Код:
if(strcmp(cmd, "/frisk", true) == 0)
{
    if(!IsPlayerCop(playerid)) SendClientMessage(playerid,COLOR_LIGHTGREEN,"You are not cop!");
    else if(IsPlayerInAnyVehicle(playerid)) SendClientMessage(playerid,COLOR_LIGHTGREEN,"You can't use this cmd in vehicle!");
    else{
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "Usage: /frisk [PlayerID]");
        new otherplayer = strval(tmp); // giveplayerid
        if(!IsPlayerConnected(otherplayer)) SendClientMessage(playerid,COLOR_LIGHTGREEN,"Invalid player ID!");
        else if(otherplayer == playerid) SendClientMessage(playerid,COLOR_LIGHTGREEN,"You can't frisk yourself!");
        else if(IsPlayerInAnyVehicle(otherplayer)) SendClientMessage(playerid,COLOR_LIGHTGREEN,"That player is in vehicle!");
        else{
            new string[128],szName[MAX_PLAYER_NAME + 1];
            GetPlayerName(otherplayer, szName, MAX_PLAYER_NAME);
            format(string,sizeof(string),"_______|- %s's Weapons -|_______", szName);
            SendClientMessage(playerid,COLOR_LIGHTGREEN,string);
            for(slot = 0; slot != 13; slot++)
            {
                GetPlayerWeaponData(otherplayer, slot, weap, ammo);
                if(weap != 0 && ammo != 0)
                    Count++;
            }
            if(!Count < 1) SendClientMessage(playerid,COLOR_LIGHTGREEN,"No Weapons found!");
            else{
                string[0] = '\0';
                new WeapName[32], weap, ammo, x;
                for(slot = 0; slot != 13; slot++)
                {
                    GetPlayerWeaponData(otherplayer, slot, weap, ammo);
                    if(weap != 0 && ammo != 0)
                    {
                        GetWeaponName(weap, WeapName, sizeof(WeapName));
                        format(string,sizeof(string),"%s%s (%d), ",string, WeapName, ammo),x++;
                        if(x > 4)
                        {
                            x = 0;
                            string[strlen(string) - 2] = 0;
                            SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
                            string[0] = '\0';
                        }
                    }
                }
                if(x > 0)
                {
                    string[strlen(string) - 2] = '.';
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
                }
            }
        }
    }
    return 1;
}



Re: Impossible! - Lajko1 - 31.10.2013

Umm Tag mismatch warning on this line
pawn Код:
if(!Count < 1) SendClientMessage(playerid,COLOR_LIGHTGREEN,"No Weapons found!");
and when I frisk someone it says he don't have weapons even if he have them.. I guess it's because this tag mismatch warning..


Re: Impossible! - Lajko1 - 31.10.2013

Okay I fixed it I had to remove "!" umm can you please just add players to point? so if player is not close it will say "you are not close enough to frisk that player"


Re: Impossible! - Jefff - 31.10.2013

pawn Код:
if(strcmp(cmd, "/frisk", true) == 0)
{
    if(!IsPlayerCop(playerid)) SendClientMessage(playerid,COLOR_LIGHTGREEN,"You are not cop!");
    else if(IsPlayerInAnyVehicle(playerid)) SendClientMessage(playerid,COLOR_LIGHTGREEN,"You can't use this cmd in vehicle!");
    else{
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "Usage: /frisk [PlayerID]");
        new otherplayer = strval(tmp); // giveplayerid
        if(!IsPlayerConnected(otherplayer)) SendClientMessage(playerid,COLOR_LIGHTGREEN,"Invalid player ID!");
        else if(otherplayer == playerid) SendClientMessage(playerid,COLOR_LIGHTGREEN,"You can't frisk yourself!");
        else if(IsPlayerInAnyVehicle(otherplayer)) SendClientMessage(playerid,COLOR_LIGHTGREEN,"That player is in vehicle!");
        else{
            new Float:X, Float:Y, Float:Z;
            GetPlayerPos(playerid, X, Y, Z);
            if(!IsPlayerInRangeOfPoint(otherplayer, Range_Here, X, Y, Z)) SendClientMessage(playerid,COLOR_LIGHTGREEN,"You are not close enough to frisk that player!");
            else{
                new string[128],szName[MAX_PLAYER_NAME + 1];
                GetPlayerName(otherplayer, szName, MAX_PLAYER_NAME);
                format(string,sizeof(string),"_______|- %s's Weapons -|_______", szName);
                SendClientMessage(playerid,COLOR_LIGHTGREEN,string);
                for(slot = 0; slot != 13; slot++)
                {
                    GetPlayerWeaponData(otherplayer, slot, weap, ammo);
                    if(weap != 0 && ammo != 0)
                        Count++;
                }
                if(!Count) SendClientMessage(playerid,COLOR_LIGHTGREEN,"No Weapons found!");
                else{
                    string[0] = '\0';
                    new WeapName[32], weap, ammo, x;
                    for(slot = 0; slot != 13; slot++)
                    {
                        GetPlayerWeaponData(otherplayer, slot, weap, ammo);
                        if(weap != 0 && ammo != 0)
                        {
                            GetWeaponName(weap, WeapName, sizeof(WeapName));
                            format(string,sizeof(string),"%s%s (%d), ",string, WeapName, ammo),x++;
                            if(x > 4)
                            {
                                x = 0;
                                string[strlen(string) - 2] = 0;
                                SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
                                string[0] = '\0';
                            }
                        }
                    }
                    if(x > 0)
                    {
                        string[strlen(string) - 2] = '.';
                        SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
                    }
                }
            }
        }
    }
    return 1;
}



Re: Impossible! - Lajko1 - 31.10.2013

Well thank you I tested it on myself and it's working exactly what I wanted I already reped you ^^