Value problem..?
#1

Hello everyone, I am trying to create a music player recently, and I am having a small problem.
I wish to create a few cmds which will play songs when used, like:

/play 1 - song id 1
/play 2 - song id 2
etc...

But, when I am using:

cmd: play 1(playerid, params[])
{
code..
return 1;
}

etc, I am getting these errors:

pawn Код:
C:\Users\xxx\Desktop\musicplayer.pwn(135) : error 001: expected token: "(", but found "-integer value-"
C:\Users\xxx\Desktop\musicplayer.pwn(135) : error 001: expected token: ";", but found "("
C:\Users\xxx\Desktop\musicplayer.pwn(138) : error 010: invalid function or declaration
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.
Now, I know that it shouldn't be like that, but I am a newbie scripter, and I was wondering how to make that work, thanks ahead.
Reply
#2

ZCMD cannot get space in the command's name. Basically, it's: cmd_%s (%s = command's name).
pawn Код:
CMD:play( playerid, params[ ] )
{
    if( isnull( params ) ) return SendClientMessage( playerid, -1, "Usage: /play <1-N>" );
    if( !IsNumeric( params ) ) return SendClientMessage( playerid, -1, "You need to enter a number" );
   
    new
        song = strval( params )
    ;
    if( song < 0 || song > N ) return SendClientMessage( playerid, -1, "between 1 and N" ); // CHANGE N
    switch( song )
    {
        case 1: // play the song 1
        case 2: // play the song 2
        // ..
        // case N: // play the song N
    }
    return 1;
}
pawn Код:
stock IsNumeric( const string[ ] )
{
    for( new i = 0, j = strlen( string ); i < j; i++ ) if( string[ i ] > '9' || string[ i ] < '0' ) return 0;
    return 1;
}
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
ZCMD cannot get space in the command's name. Basically, it's: cmd_%s (%s = command's name).
pawn Код:
CMD:play( playerid, params[ ] )
{
    if( isnull( params ) ) return SendClientMessage( playerid, -1, "Usage: /play <1-N>" );
    if( !IsNumeric( params ) ) return SendClientMessage( playerid, -1, "You need to enter a number" );
   
    new
        song = strval( params )
    ;
    if( song < 0 || song > N ) return SendClientMessage( playerid, -1, "between 1 and N" ); // CHANGE N
    switch( song )
    {
        case 1: // play the song 1
        case 2: // play the song 2
        // ..
        // case N: // play the song N
    }
    return 1;
}
pawn Код:
stock IsNumeric( const string[ ] )
{
    for( new i = 0, j = strlen( string ); i < j; i++ ) if( string[ i ] > '9' || string[ i ] < '0' ) return 0;
    return 1;
}
Thanks, again...
Reply
#4

Now if you need the rest(You wanna know how it's done) like /play 1, you need to use strcmp and check if player used "1", then play the URL for him, and voila.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)