Issue with 2 commands [sscanf]
#1

I wrote this command last night, and when you do it everything works except the fact that when you type the command, you're the one that's affected. I tried to do it so you do "/k9attack ID" and it would force the other player into a "tazed" state, but it does it to the person who writes the command, here's the code..

pawn Код:
command(k9attack, playerid, params[])
{
    if(Player[playerid][Faction] == 1)
    {
        new id;
        {
            TogglePlayerControllable(id, false);
            ApplyAnimation(id,"CRACK","crckdeth2",4.1,1,1,1,1,1);
            pTazed[id] = 1;
            SetTimerEx("Tazed", 10000, 0, "d", id);
            SendClientMessage(id, 0xFF0000FF, "You've been subdued by the police dog! (( 60 seconds ))");
        }
        pTazed[id] = 1;
        {
            SendClientMessage(playerid, RED, "You have released the attack dog!");
            new string[128];
            format(string, sizeof(string), "%s removes the leash from the attack dog, releasing it as it chases down the suspect.",MaskOnOff(playerid));
            CloseMessage(playerid, ACTION, string);
        }
        {
            new action[128], string[157];
            if(sscanf(params, "s[128]", action))
            format(string, sizeof(string), "The police dog bites the suspect, tackling him/her to the ground (( Police Dog ))", action, MaskOnOff(playerid));
            CloseMessage(playerid, ACTION, string);
        }
    }
    else return SendClientMessage(playerid, WHITE, "You're not part of the SCPD!");
    return 1;
}
I've also got another issue, which is quite basic, except I can't figure out why it won't work. I want /PM to be available to VIP's and administrators. When you do "/PM <ID> <Message>" nothing happens.

pawn Код:
command(pm, playerid, params[])
{
    if(Player[playerid][DonatorLevel] >= 1)
    {
        if(Player[playerid][AdminLevel] >= 1)
        {
            new id, message[128], string[152];
            if(sscanf(params,"us[128]", id, message)) return SendClientMessage(playerid, WHITE, "Server: /PM [playerid/name] [message]");
            {
                if(id != INVALID_PLAYER_ID)
                {
                    if(id != playerid)
                    {
                        format(string, sizeof(string), "[PM from %s(%d)] %s", RemoveUnderScore(playerid), playerid, message);
                        SendClientMessage(id, YELLOW, string);
                        format(string, sizeof(string), "[PM to %s(%d)] %s", RemoveUnderScore(id), id, message);
                        SendClientMessage(playerid, YELLOW, string);
                    }
                    else return SendClientMessage(playerid, WHITE, "You cannot send a PM to yourself.");
                }
                else return SendClientMessage(playerid, WHITE, "That player is not connected.");
            }
        }
        else return SendClientMessage(playerid, WHITE, "You're not an administrator!");
    }
    else return SendClientMessage(playerid, WHITE, "You're not a VIP! [/VIPHelp]");
    return 1;
}
Reply
#2

At the first command you use new id;
But you don't set it to the person you want to affect. You just leave it 0.
So playerid 0 will always get affected.
You should use scanff like you did a few lines below:
if(sscanf(params, "u", id))
Something like this. I'm still not sure if everything works now, because the whole cmd looks a bit wierd.
Reply
#3

Learn how to use sscanf, yo. And i dont know what is "ACTION" in CloseMessage function?
Anyway,im not sure but first command should work -
Quote:

command(k9attack, playerid, params[])
{
if(Player[playerid][Faction] == 1)
{
new id;
new tazedtimer;
if(sscanf(params,"u",id)) return SendClientMessage(playerid,WHITE,"Use /k9attack [playerid]");
if(pTazed[id] == 0)
{
TogglePlayerControllable(id, false);
ApplyAnimation(id,"CRACK","crckdeth2",4.1,1,1,1,1, 1);
pTazed[id] = 1;
tazedtimer = SetTimerEx("Tazed", 10000, 0, "d", id);
SendClientMessage(id, 0xFF0000FF, "You've been subdued by the police dog! (( 60 seconds ))");
}
else if(pTazed[id] == 1)
{
SendClientMessage(playerid, RED, "You have released the attack dog!");
new string[128];
KillTimer(tazedtimer);
format(string, sizeof(string), "%s removes the leash from the attack dog, releasing it as it chases down the suspect.",MaskOnOff(playerid));
CloseMessage(playerid, ACTION, string);
}
//There is no need for string??
CloseMessage(playerid,ACTION,"The police dog bites the suspect, tackling him/her to the ground (( Police Dog ))");
}
else return SendClientMessage(playerid, WHITE, "You're not part of the SCPD!");
return 1;
}

Reply
#4

ACTION is the colour of /me's and /do's, I find it easier to catalog colours by what they're used for rather than calling them things like "LIGHTPURPLE".

Thanks for the replies, I'll take a look and report back. Like I said I'm learning.
Reply
#5

It works, thank you, +rep for both of you. However there's an issue (but I think it's a streamer issue): When I do "/k9attack ID" I don't see the animation on the other player, but the person who's had the command used on them does.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)