/fuck if someone in Range
#1

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

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

yea. but please add that. isplayerinrange
Reply
#4

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.");
Reply
#5

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

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

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

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

https://sampwiki.blast.hk/wiki/format
4char
Reply
#9

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

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);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)