How do i put this together.. ((Cmds))
#1

I have this script for searching with isplayerinrangeofpoint but it doesnt seem to work if i put it together can anyone show me how i used else and else if etc..
pawn Код:
CMD:search(playerid, params[])
        {
                if (hung_IsPlayerAthunger (playerid))
          {
        if (isfilling[playerid]) return SendClientMessage(playerid,0xFFC800FF,"You are already eating!");
        if (hungers[playerid]>80) return SCM(playerid, red,"You are not hungry!");
        TogglePlayerControllable(playerid,0);
        isfilling[playerid] = 1;
        timerfill[playerid] = SetTimerEx("timer_fill",5500,true,"i",playerid); //setting refueltimer
        }
        return 1;
        }
            CMD:searchammu(playerid, params[])
{
        if (isfilling[playerid]) return SendClientMessage(playerid,0xFFC800FF,"You are already searching!");
        if (!ammu_IsPlayerAtammu (playerid)) return SendClientMessage(playerid, red,"You are not at a ammunation!");
        {
        TogglePlayerControllable(playerid,0);
        timerammu[playerid] = SetTimerEx("timer_ammu",5000,true,"i",playerid); //setting refueltimer
        isfilling[playerid] = 1;//resetting anti-spam thingy :3
        }
        return 1;
    }
            CMD:searchbase(playerid, params[])
{
        if (isfilling[playerid]) return SendClientMessage(playerid,0xFFC800FF,"You are already searching!");
        if (!base_IsPlayerAtme (playerid)) return SendClientMessage(playerid, red,"You are not at the base!");
        {
        TogglePlayerControllable(playerid,0);
        isfilling[playerid] = 1;//resetting anti-spam thingy :3
        timerbase[playerid] = SetTimerEx("timer_base",5000,true,"i",playerid); //setting refueltimer
        }
        return 1;
    }
Reply
#2

You can type
pawn Код:
/search
// Displays About Food
// OR
/search <Ammu/Base>

// --
/search ammu
// Displays About Ammunation
/search base
// Displays About Bases
pawn Код:
CMD:search( playerid, params[ ] )
{
    if( isnull( params ) )
    {
        if( hung_IsPlayerAthunger( playerid ) )
        {
            if( isfilling[ playerid ] ) return SendClientMessage( playerid, 0xFFC800FF, "You are already eating!" );
            if( hungers[ playerid ] > 80 ) return SCM( playerid, red, "You are not hungry!" );
            TogglePlayerControllable( playerid, 0 );
            isfilling[ playerid ] = 1;
            timerfill[ playerid ] = SetTimerEx( "timer_fill", 5500, true, "i", playerid ); //setting refueltimer
        }
    }
    if( !strcmp( params, "ammu", true ) )
    {
        if( isfilling[ playerid ] ) return SendClientMessage( playerid, 0xFFC800FF, "You are already searching!" );
        if( !ammu_IsPlayerAtammu( playerid ) ) return SendClientMessage( playerid, red, "You are not at a ammunation!" );
        TogglePlayerControllable( playerid, 0 );
        timerammu[ playerid ] = SetTimerEx( "timer_ammu", 5000, true, "i", playerid ); //setting refueltimer
        isfilling[ playerid ] = 1; //resetting anti-spam thingy :3
    }
    else if( !strcmp( params, "base", true ) )
    {
        if( isfilling[ playerid ] ) return SendClientMessage( playerid, 0xFFC800FF, "You are already searching!" );
        if( !base_IsPlayerAtme( playerid ) ) return SendClientMessage( playerid, red, "You are not at the base!" );
        TogglePlayerControllable(p layerid, 0 );
        isfilling[ playerid ] = 1; //resetting anti-spam thingy :3
        timerbase[ playerid ] = SetTimerEx( "timer_base", 5000, true, "i", playerid ); //setting refueltimer
    }
    else SendClientMessage( playerid, -1, "Usage: /search OR /search <Ammu/Base>" );
    return 1;
}
Reply
#3

Quote:
Originally Posted by Dwane
Посмотреть сообщение
You can type
pawn Код:
/search
// Displays About Food
// OR
/search <Ammu/Base>

// --
/search ammu
// Displays About Ammunation
/search base
// Displays About Bases
pawn Код:
CMD:search( playerid, params[ ] )
{
    if( isnull( params ) )
    {
        if( hung_IsPlayerAthunger( playerid ) )
        {
            if( isfilling[ playerid ] ) return SendClientMessage( playerid, 0xFFC800FF, "You are already eating!" );
            if( hungers[ playerid ] > 80 ) return SCM( playerid, red, "You are not hungry!" );
            TogglePlayerControllable( playerid, 0 );
            isfilling[ playerid ] = 1;
            timerfill[ playerid ] = SetTimerEx( "timer_fill", 5500, true, "i", playerid ); //setting refueltimer
        }
    }
    if( !strcmp( params, "ammu", true ) )
    {
        if( isfilling[ playerid ] ) return SendClientMessage( playerid, 0xFFC800FF, "You are already searching!" );
        if( !ammu_IsPlayerAtammu( playerid ) ) return SendClientMessage( playerid, red, "You are not at a ammunation!" );
        TogglePlayerControllable( playerid, 0 );
        timerammu[ playerid ] = SetTimerEx( "timer_ammu", 5000, true, "i", playerid ); //setting refueltimer
        isfilling[ playerid ] = 1; //resetting anti-spam thingy :3
    }
    else if( !strcmp( params, "base", true ) )
    {
        if( isfilling[ playerid ] ) return SendClientMessage( playerid, 0xFFC800FF, "You are already searching!" );
        if( !base_IsPlayerAtme( playerid ) ) return SendClientMessage( playerid, red, "You are not at the base!" );
        TogglePlayerControllable(p layerid, 0 );
        isfilling[ playerid ] = 1; //resetting anti-spam thingy :3
        timerbase[ playerid ] = SetTimerEx( "timer_base", 5000, true, "i", playerid ); //setting refueltimer
    }
    else SendClientMessage( playerid, -1, "Usage: /search OR /search <Ammu/Base>" );
    return 1;
}
But what if i just want it to be 1 command not with params ?
Reply
#4

"Bump"
Reply
#5

bump.
Reply
#6

Another Bump D:
Reply
#7

I don't recomment 3 to one command without params or anything.
pawn Код:
CMD:search( playerid, params[ ] )
{
    if( hung_IsPlayerAthunger( playerid ) )
    {
        if( isfilling[ playerid ] ) return SendClientMessage( playerid, 0xFFC800FF, "You are already eating/searching!" );
        if( hungers[ playerid ] > 80 ) return SCM( playerid, red, "You are not hungry!" );
        TogglePlayerControllable( playerid, 0 );
        isfilling[ playerid ] = 1;
        timerfill[ playerid ] = SetTimerEx( "timer_fill", 5500, true, "i", playerid ); //setting refueltimer
        if( !ammu_IsPlayerAtammu( playerid ) ) return SendClientMessage( playerid, red, "You are not at a ammunation!" );
        timerammu[ playerid ] = SetTimerEx( "timer_ammu", 5000, true, "i", playerid ); //setting refueltimer
        if( !base_IsPlayerAtme( playerid ) ) return SendClientMessage( playerid, red, "You are not at the base!" );
        timerbase[ playerid ] = SetTimerEx( "timer_base", 5000, true, "i", playerid ); //setting refueltimer
    }
    return 1;
}
Reply
#8

Thank you .
Reply
#9

Well after that i made this of it but it still doesnt work
pawn Код:
CMD:searchtest( playerid, params[ ] )
{
    if( hung_IsPlayerAthunger( playerid ) )
    {
        if( isfilling[ playerid ] ) return SendClientMessage( playerid, 0xFFC800FF, "You are already eating/searching!" );
        if( hungers[ playerid ] > 80 ) return SCM( playerid, red, "You are not hungry!" );
        TogglePlayerControllable( playerid, 0 );
        isfilling[ playerid ] = 1;
        timerfill[ playerid ] = SetTimerEx( "timer_fill", 5500, true, "i", playerid ); //setting refueltimer
        }
        if(ammu_IsPlayerAtammu( playerid ) )
        {
        timerammu[ playerid ] = SetTimerEx( "timer_ammu", 5000, true, "i", playerid ); //setting refueltimer
        }
        if( !base_IsPlayerAtme( playerid ) )
        {
        timerbase[ playerid ] = SetTimerEx( "timer_base", 5000, true, "i", playerid ); //setting refueltimer
    }
    return 1;
}
It gives no errors or warnings but when i use it it says : Unknown command
Reply
#10

you forgot a closing bracket on the last condition and a useless one in the middle of it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)