AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Achievements (https://forums.alliedmods.net/showthread.php?t=203991)

ironskillz1 12-26-2012 06:22

Achievements
 
need help with my HNS Achievements
i got some problems

1. i doesnt save (when i change map evrything is gone)
2. it doesnt count bunnyjumps in the menu TE.X if you have bunnyhopp 10 times i should say
10/5000

please help me :)

AngeIII 12-27-2012 10:50

Re: Achievements
 
change all vJump[id] to iAchLevel[id][JUMP]

and saving doing with nvault.
to test it just enter the game player some minutes, reconnect and if achievments setted ok, this means that saving good. if not, no steam no support.

ironskillz1 12-27-2012 12:17

Re: Achievements
 
Quote:

Originally Posted by AngeIII (Post 1861227)
change all vJump[id] to iAchLevel[id][JUMP]

and saving doing with nvault.
to test it just enter the game player some minutes, reconnect and if achievments setted ok, this means that saving good. if not, no steam no support.


Code:

change all vJump[id] to iAchLevel[id][JUMP]
i tested that but it didnt work
and i dont use nosteam look at this picture !
http://i.imgur.com/IztdT.jpg



AND! i found another bug it counting other connections to so if i connect and my freind connect i say
you got 2/1000 connections

AngeIII 12-27-2012 17:18

Re: Achievements
 
line 411
vJump[ id ]++
to
iAchLevel[id][JUMP]++


as for this
PHP Code:

public client_putinserver(id) {
    
iAchLevel[id][CONNECT]++
    switch(
iAchLevel[id][CONNECT]) {
        case 
500: {
            
set_task(2.0"ReachAddict"id// Avoid playing the sound and printing the message to early.
        
}
    }
    
LoadData(id)


hard to determine, why it's called twice for different players, but anyway you can set_task for this and do increement after some time.

PHP Code:

public client_putinserver(id) {
    
set_task(1.0,"clc_put",id);
}
public 
clc_put(id)
{
     if(
is_user_connected(id))
     {
         
iAchLevel[id][CONNECT]++
         switch(
iAchLevel[id][CONNECT]) {
            case 
500: {
              
set_task(2.0"ReachAddict"id// Avoid playing the sound and printing the message to early.
         
}
         
LoadData(id)
     }


and maybe you need firstly to load all data, and after that check if(is_data_loaded[id]) do something..
this is necessary exactly for iAchLevel[id][CONNECT]
cause firstly you increase variable value, and after that with LoadData you reset it!!

ironskillz1 12-28-2012 11:26

Re: Achievements
 
It stills dont counting JUMPS and vault doesnt save or load....
but the connection problem is solved :)



here is the new code:

AngeIII 12-28-2012 14:28

Re: Achievements
 
with nvault is a lot of problems (such as a nvault is crashing and not loadning at map change.. and other.)

in your case you have called gVaultClose variable in plugin_end function but previosly you don't defined it.
you need to remove gVaultClose variable and use gVault variable instead.

as for jumps, you know that jumps has been calculated only for T?
and also you use threeDimension array OldOrigins, but it's is not needed in this codes.
new vOldOrigin[33][3];

PHP Code:

        static Distance;
        
get_user_originidvOriginid ] );
        
        
Distance get_distancevOldOrigin[id], vOrigin[id] );
        
        if( 
Distance >= 50 )
         {
              
iAchLevel[id][JUMP]++
            
        
                
client_print(id,print_chat,"you have jumped bhop %d",iAchLevel[id][JUMP]);
            if(
iAchLevel[id][JUMP] == 2500)
            {
                
TotalAchievements[read_data(1)]++
                
ColorChat(0GREEN"[Achievements]^1 %s^3 successfully unlocked the achievement^4 Bunnyhopper [1000 Cash Added]"szName)
                
emit_sound(read_data(1), CHAN_STATICszAchievementSound1.0ATTN_NORM0PITCH_NORM)
                
cm_set_user_cash(id1000);
            }
            else if(
iAchLevel[id][JUMP] == 5000)
            {
                
TotalAchievements[read_data(1)]++
                
ColorChat(0GREEN"[Achievements]^1 %s^3 successfully unlocked the achievement^4 Pro Bunnyhopper [2000 Cash Added]"szName)
                
emit_sound(read_data(1), CHAN_STATICszAchievementSound1.0ATTN_NORM0PITCH_NORM)
                
cm_set_user_cash(id2000);
            }
            else if(
iAchLevel[id][JUMP] == 10000)
            {
                
TotalAchievements[read_data(1)]++
                
ColorChat(0GREEN"[Achievements]^1 %s^3 successfully unlocked the achievement^4 Master Bunnyhopper [4000 Cash Added]"szName)
                
emit_sound(read_data(1), CHAN_STATICszAchievementSound1.0ATTN_NORM0PITCH_NORM)
                
cm_set_user_cash(id4000);
            }
            
            
vOldOriginid ] = vOriginid ];
        } 

as for plugin_end .. i think you also need to put loop for saving all players data. (1..players save(id));

and my suggestion for you try to useing SQL, SQLite.. cause it's is better with saving, and in future to integrating with WEB...

in my case server is working only when nvault file doesnt exist(I remove it and start the server). plugin creates .vault and .journal files, but after map change .journal file doesn't exist and server is crashing(probably because journal file doens't exist).
P.S. also I tried with CHMOD 777 (full permissions).

as for you if nvault is working correctly maybe try to set 777 permision for nvault folder.

ironskillz1 12-29-2012 15:37

Re: Achievements
 
i changed it but it stills doesnt show how many jumps you got and i didnt understand what you was talking about with nvault saving and loading
And should i change nvault to sql? but how i dont know sql coding


New code:

AngeIII 01-02-2013 16:06

Re: Achievements
 
oh.. finally the error is that the funtion player_spray doesnt found.

and forward for jump doesn't called at any time..

fix:
PHP Code:

public plugin_init() {
    
register_plugin("HNS Achievements"VERSION"SnusMumrikeN")
    
    
// Commands
    
register_clcmd("say /ach""Cmd_ShowAchievements")
    
register_clcmd("say /achievements""Cmd_ShowAchievements")
    
    
// Events
    
register_event("DeathMsg""eDeath""a")
    
//register_event("23", "player_spray", "a", "1=112")
    
register_event("SendAudio""TerrorWins""a""2=%!MRAD_terwin")
    
    
RegisterHamHam_Player_Jump"player""Ham_Player_Jump_Post");
    
    
// nVault
    
gVault nvault_open("AchievementSystem")


...
PHP Code:

....
public 
Ham_Player_Jump_Post( const id )
{
    if( ( 
pevidpev_flags ) & FL_ONGROUND ) && !( pevidpev_oldbuttons ) & IN_JUMP ) )
    {
        if (
get_user_team(id) == 1)
        {
            static 
Distance;
            
get_user_originidvOriginid ] );
        
            
Distance get_distancevOldOrigin[id], vOrigin[id] );
        
            if( 
Distance >= 50 && Distance <=300 )
            {
                
iAchLevel[id][JUMP]++
                
client_print(id,print_chat,"you have jumped bhop %d distance %d",iAchLevel[id][JUMP],Distance);
                if(
iAchLevel[id][JUMP] == 2500)
                {
                    
TotalAchievements[read_data(1)]++
                    
ColorChat(0GREEN"[Achievements]^1 %s^3 successfully unlocked the achievement^4 Bunnyhopper [1000 Cash Added]"szName)
                    
emit_sound(read_data(1), CHAN_STATICszAchievementSound1.0ATTN_NORM0PITCH_NORM)
                    
cm_set_user_cash(id1000);
                }
                else if(
iAchLevel[id][JUMP] == 5000)
                {
                    
TotalAchievements[read_data(1)]++
                    
ColorChat(0GREEN"[Achievements]^1 %s^3 successfully unlocked the achievement^4 Pro Bunnyhopper [2000 Cash Added]"szName)
                    
emit_sound(read_data(1), CHAN_STATICszAchievementSound1.0ATTN_NORM0PITCH_NORM)
                    
cm_set_user_cash(id2000);
                }
                else if(
iAchLevel[id][JUMP] == 10000)
                {
                    
TotalAchievements[read_data(1)]++
                    
ColorChat(0GREEN"[Achievements]^1 %s^3 successfully unlocked the achievement^4 Master Bunnyhopper [4000 Cash Added]"szName)
                    
emit_sound(read_data(1), CHAN_STATICszAchievementSound1.0ATTN_NORM0PITCH_NORM)
                    
cm_set_user_cash(id4000);
                }
            } 
            
vOldOriginid ] = vOriginid ];
        }
    }
    return 
HAM_IGNORED;


vOldOrigin[id] = vOrigin[id];
should be after if statement, and distance should chekc a limit too (for spawn jumpfix) 50<=jump_distance<=300

ironskillz1 01-03-2013 10:44

Re: Achievements
 
Your are the best thanks evrything works now! :)

ironskillz1 01-03-2013 12:07

Re: Achievements
 
okay 1 more thing :D

I have added a Player info menu its works great but
when i click on my freinds name it shows my ach not my freinds


All times are GMT -4. The time now is 13:37.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.