SA-MP Forums Archive
make this shorter? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: make this shorter? (/showthread.php?tid=256874)



make this shorter? - fissekarl - 22.05.2011

pawn Код:
forward One();
forward Two();
//etc..

public Two()
{
    GameTextForAll("~y~2",3000,4);
    SoundForAll(1056);
    return 1;
}

public One()
{
    GameTextForAll("~r~1",3000,4);
    SoundForAll(1056);
    return 1;
}

// up to go

COMMAND:countdown(playerid, params[])
{
    if(Countdown == 1) return SendClientMessage(playerid, Red, "countdown already on");
    SendClientMessage(playerid, Green, "count started");
    SetTimer("Three", 1000, 0);
    SetTimer("Two", 2000, 0);
    SetTimer("One", 3000, 0);
    SetTimer("Go", 4000, 0);
    Countdown = 1;
    return 1;
}
how to make it shorter? I dont want so many publics and all


Re: make this shorter? - fissekarl - 23.05.2011

bump, also another question

pawn Код:
public OnRconLoginAttempt(ip[], password[], success)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!success)
        {
            new IP[16], string[128], pName[MAX_PLAYER_NAME];
            GetPlayerIp(i, IP, sizeof(IP));
            GetPlayerName(i, pName, sizeof(pName));
            RCONAttempts(pName, ip, password);
            if(!strcmp(ip, IP, true))
            {
                LoginAttempt[i]++;
                if(LoginAttempt[i] == 1) return SendClientMessage(i, AdminColor, "Wrong RCON login. 2 attempts left");
                if(LoginAttempt[i] == 2) return SendClientMessage(i, AdminColor, "Wrong RCON login. 1 attempts left");
                if(LoginAttempt[i] == 3)
                {
                    SendClientMessage(i, AdminColor, "banned .. ");
                    LoginAttempt[i] = 0;
                    Ban(i);
                }
            }
        }
        else
        {
            SendClientMessage(i, AdminColor, "logged in");
        }
    }
    return 1;
}
The code works perfectly fine, but it still shows the old messages? Like SERVER: Bad RCON Login. Repeated times ....., and when you logged in "SERVER: You have logged in as an admin"

I want that away, I want my own messages how to ?


Re: make this shorter? - (SF)Noobanatior - 23.05.2011

how is this
pawn Код:
forward Go(playerid);
new GoTimer[MAX_PLAYERS],GoTCount,GTStr[10];
public Go(playerid){
    switch(GoTCount){
        case 0:{
            GTStr = "~g~GO!!";
            KillTimer(GoTimer[playerid]);
            GoTimer[playerid] = 0;
        }
        default:format(GTStr,sizeof(GTStr),"~r~%d",g);
    }
    GameTextForAll(GTStr,3000,4);
    SoundForAll(1056);
    GoTCount--;
    return 1;
}

// up to go

COMMAND:countdown(playerid, params[])
{
    if(Countdown == 1) return SendClientMessage(playerid, Red, "countdown already on");
    SendClientMessage(playerid, Green, "count started");
    GoTimer[playerid] = SetTimer("Go",4000,1,"i",playerid);
    Countdown = 1;
    GoTCount = 5;
    return 1;
}



Re: make this shorter? - fissekarl - 23.05.2011

edit: didnt work well


Re: make this shorter? - Seven_of_Nine - 23.05.2011

Place a return 1; under if(!success), and under the "else" part too.


Re: make this shorter? - Austin - 23.05.2011

Quote:
Originally Posted by (SF)Noobanatior
Посмотреть сообщение
how is this
pawn Код:
forward Go(playerid);
new GoTimer[MAX_PLAYERS],GoTCount,GTStr[10];
public Go(playerid){
    switch(GoTCount){
        case 0:{
            GTStr = "~g~GO!!";
            KillTimer(GoTimer[playerid]);
            GoTimer[playerid] = 0;
        }
        default:format(GTStr,sizeof(GTStr),"~r~%d",g);
    }
    GameTextForAll(GTStr,3000,4);
    SoundForAll(1056);
    GoTCount--;
    return 1;
}

// up to go

COMMAND:countdown(playerid, params[])
{
    if(Countdown == 1) return SendClientMessage(playerid, Red, "countdown already on");
    SendClientMessage(playerid, Green, "count started");
    GoTimer[playerid] = SetTimer("Go",4000,1,"i",playerid);
    Countdown = 1;
    GoTCount = 5;
    return 1;
}
Timer and countdown variables? SIMPLIFICATION FAIL.

pawn Код:
forward Go();
new GoTCount, GTStr[10];
public Go(){
    switch(GoTCount){
        case 0: GTStr = "~g~GO!!";
        default:format(GTStr,sizeof(GTStr),"~r~%d",GoTCount);
    }
    GameTextForAll(GTStr,1500,4);
    SoundForAll(1056);
    if(GoTCount > 0)
    {
        GoTCount--;
        SetTimer("Go",1000,0);
    }
    return 1;
}

// up to go

COMMAND:countdown(playerid, params[])
{
    if(GoTCount != 0) return SendClientMessage(playerid, Red, "countdown already on");
    SendClientMessage(playerid, Green, "count started");
    SetTimer("Go",1000,0);
    GoTCount = 5;
    return 1;
}



Re: make this shorter? - fissekarl - 23.05.2011

What about the RCON thingy?


Re: make this shorter? - Austin - 23.05.2011

Ask a second question, and also, I don't think it is possible.


Re: make this shorter? - fissekarl - 23.05.2011

Then it's really ugly

it will be like this

Код:
SERVER: 3 Attempts left // mine.
SERVER: Bad admin password. Repeated attempts will get you banned. // server
but as it wont work I won't use it