SA-MP Forums Archive
/fuck if someone in Range - 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: /fuck if someone in Range (/showthread.php?tid=336346)



/fuck if someone in Range - ThamburaaN - 22.04.2012

pawn Код:
dcmd_fuck(playerid,params[])
{
    if(AccInfo[playerid][Level] >= 0)
    {
        new Index;
        new tmp[256];  tmp  = strtok(params,Index);
        new string[128];
        new fname [MAX_PLAYER_NAME];
        new PlayerName[MAX_PLAYER_NAME];

        if(!strlen(tmp)) return
        SendClientMessage(playerid, red, "Usage: /fuck [PlayerID]");
        new player1 = strval(tmp);
        GetPlayerName(player1, PlayerName, MAX_PLAYER_NAME);
        GetPlayerName(playerid, fname, sizeof(fname));
        if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
            {
            ApplyAnimation(playerid,"PED","fucku",4.0,0,0,0,0,0);
            format(string,sizeof(string)," **%s (%d) Flips %s (%d) Off.",fname,playerid,PlayerName,player1);
            SendClientMessageToAll(COLOR_WHITE, string);
                return 1;
            }
                //else return SendClientMessage(playerid,red, "%s (%d) is Not Close Enough To Flip him Off",PlayerName,player1);
             //}
        else return SendClientMessage(playerid,red, "Invaild Player ID");
    }
    else return ErrorMessages(playerid, 1);
}
Someone Please fix this. i tired putting isplayerinrange but getting error.


Re: /fuck if someone in Range - MP2 - 22.04.2012

Your code is really messy because of the way you do:

pawn Код:
if(this)
{
    if(that)
    {
        // Code
    }
    else
    {
        // Error
    }
}
else
{
    // Error
}
it's sooooooooooo much easier to read if you just use one return line:


pawn Код:
if(!this) return error;
if(!that) return error;
// Code
Reduced from 15 lines to 3.

Why are you using strtok? 'params' will contain the ENTIRE player ID/name string, there is no need to use strtok at all.


Re: /fuck if someone in Range - ThamburaaN - 22.04.2012

yea. but please add that. isplayerinrange


Re: /fuck if someone in Range - MP2 - 22.04.2012

pawn Код:
new Float:playerPos[3];
GetPlayerPos(player1, playerPos[0], playerPos[1], playerPos[2]);
if(!IsPlayerInRangeOfPoint(playerid, 50, playerPos[0], playerPos[1], playerPos[2])) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player not in range.");



Re: /fuck if someone in Range - ThamburaaN - 22.04.2012

can i just put
pawn Код:
return SendClientMessage(playerid,red, "%s (%d) is Not Close Enough To Flip him Off",PlayerName,player1);
but getting error


Re: /fuck if someone in Range - MP2 - 22.04.2012

No, you have to use format().

https://sampwiki.blast.hk/wiki/format

The grammar in your message makes no sense, the correct message would say 'You are not close enough to flip x (x) off.'.


Re: /fuck if someone in Range - ThamburaaN - 22.04.2012

.
pawn Код:
return SendClientMessage(playerid,red, "Your Not Close Enough to Flip %s (%i) Off",PlayerName,playerid);
tried Putting that but
getting this error. "number of arguments does not match definition"


Re: /fuck if someone in Range - MP2 - 22.04.2012

Quote:
Originally Posted by MP2
Посмотреть сообщение
you have to use format().

https://sampwiki.blast.hk/wiki/format
4char


Re: /fuck if someone in Range - ThamburaaN - 22.04.2012

but i have to return it. please tell.
edit: Fixed... Thanks for your Help +rep


Re: /fuck if someone in Range - Sasino97 - 22.04.2012

Quote:
Originally Posted by ThamburaaN
Посмотреть сообщение
but i have to return it. please tell.
pawn Код:
new myMsg[128];
format(myMsg, 128, "Your Not Close Enough to Flip %s (%i) Off", PlayerName, playerid);
return SendClientMessage(playerid,red, myMsg);