/slap command
#1

Hello,
I want the following command to be able to tell all players why that the player was slapped

Example "AdmCmd: Playername was slapped by Playeradmin, Reason: "

pawn Код:
if(strcmp(cmd, "/slap", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /slap [playerid/PartOfName]");
                return 1;
            }
            new playa;
            new Float:shealth;
            new Float:slx, Float:sly, Float:slz;
            playa = ReturnUser(tmp);
            if (PlayerInfo[playerid][pAdmin] >=1)
            {
                if(IsPlayerConnected(playa))
                {
                    if(playa != INVALID_PLAYER_ID)
                    {
                        GetPlayerName(playa, giveplayer, sizeof(giveplayer));
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        GiveNameSpace(sendername);
                        GiveNameSpace(giveplayer);
                        if(PlayerInfo[playerid][pAdmin] == 11) { sendername = "Secret Admin"; }
                        GetPlayerHealth(playa, shealth);
                        SetPlayerHealthEx(playa, shealth-5);
                        GetPlayerPos(playa, slx, sly, slz);
                        DOO_SetPlayerPos(playa, slx, sly, slz+5);
                        PlayerPlaySound(playa, 1130, slx, sly, slz+5);
                        printf("AdmCmd: %s slapped %s",sendername,  giveplayer);
                        format(string, sizeof(string), "AdmCmd: %s was slapped by %s",giveplayer ,sendername);
                        ABroadCast(COLOR_LIGHTRED,string,1);
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "   you are not authorized to use that command!");
            }
        }
        return 1;
    }
Reply
#2

EDIT: FAIL ME

ZCMD + SSCANF
pawn Код:
CMD:slap( playerid, params[ ] )
{
    // admin check here

    new id, ir[ 64 ];

    if ( sscanf( params, "us[64]", id, ir ) )
        return // sendclientmessage stuffs

    if ( id == INVALID_PLAYER_ID )
        return // scm stuffs

    new a[ 128 ]; format( a, sizeof a, "%s has slapped %s. reason : %s", getName( playerid ), getName( id ), ir );

    // slap stuffs here

    // abroadcast... blablabla

   SendClientMessageToAll( -1, a );

   return 1;
}

stock getName( lol )
{
    new name[24]; GetPlayerName( lol, name, 24 ); return name;
}
try this one
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)