Jump to content

[CLEO] Scoreboard update


Moderat
 Share

Recommended Posts

Hello,

 

I want to have a script which updates the scoreboard at set intervals (10 seconds, for now).

 

I managed to find some info which points out to using the 0AA8 opcode, with the 0x8A10 offset.

 

Unfortunately, I don't know how to implement this correctly in a CLEO script. Just using "0AA8: call_function_method 0x8A10" doesn't really work, and I don't really understand anything from "0AA8: call_function_method 0x4048E0 struct 0xB74494 num_params 1 pop 0 $MyCar 0@", which can be found in the opcodes.txt file in the data folder of SannyBuilder.

 

Could you please help me with the correct portion of code necessary to update the scoreboard, if you can, please? I need this to use with another script which gets the level of a player from the score that is shown in the scoreboard, so the scoreboard should be up to date.

 

This is what I tried so far:

{$CLEO .cs}
0000:

REPEAT
    WAIT 0
UNTIL 0AFA:  is_samp_available

chatmsg "{B399F1}[Tab Update]{FFFFFF} by {8DA5ED}Moderat{FFFFFF} has been loaded." -1

0B34: samp register_client_command "tab" to_label @tab_toggle

5@ = 1 // TAB UPDATE IS ON BY DEFAULT

while true
    wait 20
    if
        5@ == 1
    then
        if
            0256:   player $PLAYER_CHAR defined // IF YOU HAVE A CHARACTER (IF YOU SPAWNED)
        then
            0AA8: call_function_method 0x8A10
            chatmsg "{B399F1}[Tab Update] Updated" -1
            wait 9980
        end
    end
end

:tab_toggle
if
    5@ == 1
then
    5@ = 0
    chatmsg "{B399F1}[Tab Update] {D40000}OFF" -1
else
    5@ = 1
    chatmsg "{B399F1}[Tab Update] {00FF00}ON" -1
end
0B43: samp cmd_ret

 

Link to comment
Share on other sites

Hello,

 

The scoreboard is updated in real time. The problem is that when the player receives a reconnect to the server, the GetPlayerScore function must be used twice because on first use it detects that the player's level would be 0. The problem is with the language itself, not the scoreboard. The only way to get the right level of player is from the website but it is a bit difficult, it requires some lines of code and it takes a few seconds to find it, besides if the website is down, it doesn't work.

Link to comment
Share on other sites

1 hour ago, Tupi said:

Hello,

 

The scoreboard is updated in real time. The problem is that when the player receives a reconnect to the server, the GetPlayerScore function must be used twice because on first use it detects that the player's level would be 0. The problem is with the language itself, not the scoreboard. The only way to get the right level of player is from the website but it is a bit difficult, it requires some lines of code and it takes a few seconds to find it, besides if the website is down, it doesn't work.

 

So I guess that I can get a player's score, check if it's 0, and if it's 0 I can just get it again, right?

Link to comment
Share on other sites

33 minutes ago, Moderat said:

 

So I guess that I can get a player's score, check if it's 0, and if it's 0 I can just get it again, right?

Yes, but this method makes the code double

1@ = GetPlayerScore(0@)

if 1@ > 0
then
       ... some code
else
      1@ = GetPlayerScore(0@)
      if 1@ > 0
      then
             ... some code
     end
end

 

The simplest is to run the code twice

1@ = GetPlayerScore(0@)

if 1@ > 0
then
       ... some code
else chatmsg "Player level unrecognized. Please try again" -1
end

 

Link to comment
Share on other sites

1 hour ago, Tupi said:

Yes, but this method makes the code double

1@ = GetPlayerScore(0@)

if 1@ > 0
then
       ... some code
else
      1@ = GetPlayerScore(0@)
      if 1@ > 0
      then
             ... some code
     end
end

 

The simplest is to run the code twice

1@ = GetPlayerScore(0@)

if 1@ > 0
then
       ... some code
else chatmsg "Player level unrecognized. Please try again" -1
end

 

 

The idea is to have the player's level eventually, and not show an error.

 

What do you think of this implementation?

 

7@ = SAMP.GetPlayerScore(6@)
if
	7@ == 0
then
	7@ = SAMP.GetPlayerScore(6@)
end
8@ = SAMP.GetPlayerNickname(6@)
10@ = SAMP.GetPlayerColor(6@)
if
	10@ == 16777215
then
	chatmsg "{F1C40F}[InfoTaxi]{B399F1} %s are nivel %d si este {FFFFFF}Civil" -1 8@ 7@
end
if
	10@ == 16776960
then
	chatmsg "{F1C40F}[InfoTaxi]{B399F1} %s are nivel %d si este {FFFF00}Taximetrist" -1 8@ 7@
end

 

This section of code is in the "while" loop - should I have an additional "wait" before the second "GetPlayerScore"? If yes, how many miliseconds do you suggest? I mean, do you have enough experience with this part to know if an additional "wait" is necessary and how many miliseconds should this wait last before the script should do "GetPlayerScore" again?

 

Thank you very much for your assistance.

Edited by Moderat
Link to comment
Share on other sites

This seems to work fine for now - I will see in the following days if it works well at all times.

 

7@ = SAMP.GetPlayerScore(6@)
while 7@ < 1
	wait 10
	7@ = SAMP.GetPlayerScore(6@)
end
8@ = SAMP.GetPlayerNickname(6@)
10@ = SAMP.GetPlayerColor(6@)
if
	10@ == 16777215
then
	chatmsg "{F1C40F}[InfoTaxi]{B399F1} %s are nivel %d si este {FFFFFF}Civil" -1 8@ 7@
end

 

Thank you very much again for your assistance!

Edited by Moderat
Link to comment
Share on other sites

25 minutes ago, Tupi said:

Or you can try this

 

1@ = GetPlayerScore(0@)

repeat
wait 50
1@ = GetPlayerScore(0@)
until 1@ > 0

 

 

It's basically the same thing, except you set the waiting time to 50ms, unless I don't know something and "repeat" works differently in the background in comparison to "while".

 

I did a test, and after 30ms it already got the level, so I may increase the time to 15ms or something.

 

"GetPlayerScore" doesn't force an update of the scoreboard and hence it doesn't put stress on the server, right?

Edited by Moderat
Link to comment
Share on other sites

  • Nic locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.