[FilterScript] Cyanide's Bench-Pressing System ( Bench Pressing in Multiplayer )
#1

→ About

Cyanide's Bench-Pressing System allows multiplayer users to experience the singleplayer feature of bench-pressing.

→ Advantages
  • Plug N' Play
  • Ability to add your own bench-press locations.
  • Preloaded barbells.
  • Useful Callbacks
→ Disadvantages
  • Unable to increase the muscle stat ( Impossible in SA:MP )
→ Optional Callbacks

pawn Код:
public OnPlayerBenchPress( playerid, reps )
{
      printf( "ID %i has just benched, increasing his current reps to %i.", playerid, reps );
}

public OnPlayerStartBenchPress( playerid, result )
{
      switch( result )
      {
           case 0:
           {
                SendClientMessage( playerid, 0x0, "You're not allowed to bench, someone is currently using it!" );
           }
           case 1:
           {
                SendClientMessage( playerid, 0x0, "{FFFFFF}You're now starting to bench, use the spacebar to increase the power bar." );
           }
      }
}

public OnPlayerExitBenchPress( playerid, reps )
{
       printf( "Player %i has stopped bench pressing, and has done %i reps!", playerid, reps );
}
→ Functions ( benchPress.inc required )
pawn Код:
OnPlayerBenchPress( playerid, reps ) - Called when someone does a bench rep.
OnPlayerStartBenchPress( playerid, result ) - Called when someone starts to bench-press
OnPlayerExitBenchPress( playerid, reps ) - Called when a player stops bench-pressing.
→ Codes

Код:
OnPlayerStartBenchPress ( result )
         0 - Failure.
         1 - Success.
→ Video

[ame]http://www.youtube.com/watch?v=2IEXZ3c8NYI[/ame]
→ Download

Filterscript + .inc download.
Progress Bar download.
YSI package download

→ Tutorial

Tutorial List

→ Credits

Код:
Cyanide - Project Launcher & Developer
Grim_ - Testing.
****** - YSI.
Toribio - Progress Bar.
SA-MP Team - San Andreas Multiplayer Modification.
Reply
#2

Thumbs up !
Reply
#3

Awesome, gratz.
Reply
#4

Gotta say.. the way you synced it, is perfect. Nice one.
Reply
#5

Thank you very much sir!
You can use 1 progress bar FOR ALL PLAYERS
Reply
#6

Quote:
Originally Posted by wups
Посмотреть сообщение
Thank you very much sir!
You can use 1 progress bar FOR ALL PLAYERS
No problem.

If I used one progress bar and multiple players are benching at once, it would cause a serious dysfunction. If you take a look at the progress include that I used for the filterscript, and looked at the source, you'll notice that it's not based off of clientids. Also, the parameters of the functions regarding value update clearly show it's not based off of clientids.
Reply
#7

Quote:
Originally Posted by Cyanide
Посмотреть сообщение
No problem.

If I used one progress bar and multiple players are benching at once, it would cause a serious dysfunction. If you take a look at the progress include that I used for the filterscript, and looked at the source, you'll notice that it's not based off of clientids. Also, the parameters of the functions regarding value update clearly show it's not based off of clientids.
It wont. I'm using two gauges for my server : Fuel, and vehicle health. There are ~100 online players. And you know what? I use only TWO Progress bars.
It has been tested, don't worry I know what i'm talking.
Reply
#8

Quote:
Originally Posted by wups
Посмотреть сообщение
It wont. I'm using two gauges for my server : Fuel, and vehicle health. There are ~100 online players. And you know what? I use only TWO Progress bars.
It has been tested, don't worry I know what i'm talking.
May you send me the IP address through PM? I don't believe what you're saying. If you look at CreateProgressBar ( below ), you'll notice it's creating the progress bar, and assigning the submitted parameters to the array. The first dimesion of Bars is MAX_BARS which equals MAX_TEXT_DRAWS divided by three. Which proves it's not assigned to clientids.

pawn Код:
stock Bar:CreateProgressBar(Float:x, Float:y, Float:width=55.5, Float:height=3.2, color, Float:max=100.0)
{
    new
        barid;

    for(barid = 0; barid < sizeof Bars; ++barid)
        if(!Bars[barid][pb_created]) break;

    if(Bars[barid][pb_created] || barid == sizeof Bars)
        return INVALID_BAR_ID;

    new Text:in_t = Bars[barid][pb_t1] = TextDrawCreate(x, y, "_");
    TextDrawUseBox      (in_t, 1);
    TextDrawTextSize    (in_t, x + width, 0.0);
    TextDrawLetterSize  (in_t, 1.0, height / 10);
    TextDrawBoxColor    (in_t, 0x00000000 | (color & 0x000000FF));

    in_t = Bars[barid][pb_t2] = TextDrawCreate(x + 1.2, y + 2.15, "_");
    TextDrawUseBox      (in_t, 1);
    TextDrawTextSize    (in_t, x + width - 2.0, 0.0);
    TextDrawLetterSize  (in_t, 1.0, height / 10 - 0.35);
    TextDrawBoxColor    (in_t, (color & 0xFFFFFF00) | (0x66 & ((color & 0x000000FF) / 2)));

    in_t = Bars[barid][pb_t3] = TextDrawCreate(x + 1.2, y + 2.15, "_");
    TextDrawTextSize    (in_t, pb_percent(x, width, max, 1.0), 0.0);
    TextDrawLetterSize  (in_t, 1.0, height / 10 - 0.35);
    TextDrawBoxColor    (in_t, color);

    Bars[barid][pb_x] = x;
    Bars[barid][pb_y] = y;
    Bars[barid][pb_w] = width;
    Bars[barid][pb_h] = height;
    Bars[barid][pb_m] = max;
    Bars[barid][pb_color] = color;
    Bars[barid][pb_created] = true;
    return Bar:barid;
}
Also, the function used to update the bar and show it to the player isn't assigned to clientids ( Below ). The only reason playerid is used, is for SA:MP natives relevant to the include. Therefore, what you're saying is false.

pawn Код:
stock SetProgressBarValue(Bar:barid, Float:value)
{
    if(barid == INVALID_BAR_ID || Bar:MAX_BARS < barid < Bar:-1)
        return 0;

    if(Bars[_:barid][pb_created])
    {
        value =
            (value < 0.0) ? (0.0) : (value > Bars[_:barid][pb_m]) ? (Bars[_:barid][pb_m]) : (value);

        TextDrawUseBox(Bars[_:barid][pb_t3], value > 0.0);

        Bars[_:barid][pb_v] = value;

        TextDrawTextSize(Bars[_:barid][pb_t3],
            pb_percent(Bars[_:barid][pb_x], Bars[_:barid][pb_w], Bars[_:barid][pb_m], value), 0.0);

        return 1;
    }
    return 0;
}

stock UpdateProgressBar(Bar:barid, playerid=INVALID_PLAYER_ID)
{
    if(playerid == INVALID_PLAYER_ID)
    {
        return ShowProgressBarForAll(barid);
    } else {
        return ShowProgressBarForPlayer(playerid, barid);
    }
}

stock ShowProgressBarForPlayer(playerid, Bar:barid)
{
    if(IsPlayerConnected(playerid) && barid != INVALID_BAR_ID && Bar:-1 < barid < Bar:MAX_BARS)
    {
        if(!Bars[_:barid][pb_created])
            return 0;

        TextDrawShowForPlayer(playerid, Bars[_:barid][pb_t1]);
        TextDrawShowForPlayer(playerid, Bars[_:barid][pb_t2]);
        TextDrawShowForPlayer(playerid, Bars[_:barid][pb_t3]);
        return 1;
    }
    return 0;
}
Reply
#9

Great FS. Keep up the good work.
Reply
#10

Heh, i don't know how will you check in my server how much progress bars i have created.(also check j_fades, it also uses 1 textdraw)

Here's the secret:
You can create 1 textdraw(a box) and show it for all players yes? Okay, then: if you change the BOX SIZE, nothing will happen to any players. But when you reshow it for the player it does(thats how UpdateProgressBar works). So the point is: You can change the Bars value(the box size), and Update it ONLY FOR ONE PLAYER.

Here's my code:
pawn Код:
SetProgressBarValue(HealthBar, VehicleHealth);
        UpdateProgressBar(HealthBar, playerid);
You ask me why i studied this? Imagine a server with 500 slots.As we both know - 1 Progress bar = 3 text draws. Therefore 1 Progress Bar For Each Player 3*500 = 1500 TEXTDRAWS. That's insane.

Other than that:
bench_power[ playerid ]
bench_reps[ playerid ]
Is also not needed for every player, since it contains a constant string.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)