SA-MP Forums Archive
Problems with commands - 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: Problems with commands (/showthread.php?tid=402201)



Problems with commands - zacklogan - 25.12.2012

pawn Код:
C:\Users\Public\Videos\Sample Videos\pawno\troll.pwn(43) : error 010: invalid function or declaration
C:\Users\Public\Videos\Sample Videos\pawno\troll.pwn(47) : error 010: invalid function or declaration
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext,"/troll",true)==0)
    {
        if(IsPlayerAdmin(playerid))
        {
            new string[128];
            new adminname[MAX_PLAYER_NAME];
            for (new i = 0; i != MAX_PLAYERS; ++i)
            {
                if (IsPlayerConnected(i))
                {
                    PlayAudioStreamForPlayer(i, "https://soundcloud.com/bigred9921/u-mad-bro-song-by-teamheadkick/download");
                    GetPlayerName(playerid, adminname, sizeof(adminname));
                    format(string, sizeof(string), "[TROLL]RCON Administrator %s(ID:%d) has trolled you! Type /stopmusic if you don't like the music!", adminname, adminname);
                    }
                }
            }
        }
    }
   
    if(strcmp(cmdtext,"/stopmusic",true)==0)
    {
        StopAudioStreamForPlayer(playerid);
        SendClientMessage(playerid, awesome_blue, "Troll music stopped!);
        return 1;
        }
    }
}
How do i fix this?


Re: Problems with commands - jNkk - 25.12.2012

Hi zack. It's me juNkiez from minecraft if you remember me. Friends with noah xD!

Please switch to ZCMD. Strtok or whatever its called is very slow.
Also, post the lines number


Re: Problems with commands - zacklogan - 25.12.2012

Yeah i remember you. Line 43 is if(strcmp(cmdtext,"/stopmusic",true)==0) and 47 is return 1;


Re : Problems with commands - [HRD]Mar1 - 25.12.2012

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext,"/troll",true)==0)
    {
        if(IsPlayerAdmin(playerid))
        {
            new string[128];
            new adminname[MAX_PLAYER_NAME];
            for (new i = 0; i != MAX_PLAYERS; ++i)
            {
                if (IsPlayerConnected(i))
                {
                    PlayAudioStreamForPlayer(i, "https://soundcloud.com/bigred9921/u-mad-bro-song-by-teamheadkick/download");
                    GetPlayerName(playerid, adminname, sizeof(adminname));
                    format(string, sizeof(string), "[TROLL]RCON Administrator %s(ID:%d) has trolled you! Type /stopmusic if you don't like the music!", adminname, adminname);
                }
            }
        }
        return 1;
    }
   
    if(strcmp(cmdtext,"/stopmusic",true)==0)
    {
        StopAudioStreamForPlayer(playerid);
        SendClientMessage(playerid, awesome_blue, "Troll music stopped!");
        return 1;
    }
    return 0;
 }



Respuesta: Problems with commands - Strier - 25.12.2012

Switch to ZCMD
https://sampforum.blast.hk/showthread.php?tid=91354


Re: Problems with commands - jNkk - 25.12.2012

You forgot to return 1; the first command.

pawn Код:
CMD:troll(playerid, params[])
    {
        if(IsPlayerAdmin(playerid))
        {
            new string[128];
            new adminname[MAX_PLAYER_NAME];
            for (new i = 0; i != MAX_PLAYERS; ++i)
            {
                if (IsPlayerConnected(i))
                {
                    PlayAudioStreamForPlayer(i, "https://soundcloud.com/bigred9921/u-mad-bro-song-by-teamheadkick/download");
                    GetPlayerName(playerid, adminname, sizeof(adminname));
                    format(string, sizeof(string), "[TROLL]RCON Administrator %s(ID:%d) has trolled you! Type /stopmusic if you don't like the music!", adminname, adminname);
                    }
                }
            }
        }
        return 1;
    }

CMD:stopmusic(playerid, params[])
    {
        StopAudioStreamForPlayer(playerid);
        SendClientMessage(playerid, awesome_blue, "Troll music stopped!");
        return 1;
        }
    }
}



Re: Problems with commands - Typhome - 25.12.2012

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext,"/troll",true)==0)
    {
        if(IsPlayerAdmin(playerid))
        {
            new string[128];
            new adminname[MAX_PLAYER_NAME];
            for (new i = 0; i != MAX_PLAYERS; ++i)
            {
                if (IsPlayerConnected(i))
                {
                    PlayAudioStreamForPlayer(i, "https://soundcloud.com/bigred9921/u-mad-bro-song-by-teamheadkick/download");
                    GetPlayerName(playerid, adminname, sizeof(adminname));
                    format(string, sizeof(string), "[TROLL]RCON Administrator %s(ID:%d) has trolled you! Type /stopmusic if you don't like the music!", adminname, playerid);
                }
            }
        }
        return 1;
    }
   
    if(strcmp(cmdtext,"/stopmusic",true)==0)
    {
        StopAudioStreamForPlayer(playerid);
        SendClientMessage(playerid, awesome_blue, "Troll music stopped!);
        return 1;
    }
}



Re: Problems with commands - zacklogan - 25.12.2012

Thanks all of you