AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Give experience on roundstart (https://forums.alliedmods.net/showthread.php?t=240186)

egbertjan 05-10-2014 12:25

Give experience on roundstart
 
Hello guys,

I've been trying to give experience to players when the round start. I'm trying to do this with a loop, however the server is crashing upon execute. I'm wondering what's wrong with this:

Code:

public RoundStart() {
        for (new i=0; i < 33; i++){
                if(!is_user_bot(i)) {
                RoundExperience(i)
                }
        }
}

public RoundExperience(id) {
        Give_Xp(id, 20)
}


connoisseur 05-10-2014 12:49

Re: Give experience on roundstart
 
Use get_players

egbertjan 05-10-2014 13:32

Re: Give experience on roundstart
 
Thank you :)

egbertjan 05-10-2014 13:48

Re: Give experience on roundstart
 
Actually I tried to do it with this:

Code:

        new players[32], num
        get_players(players,num,"a")       
       
        for(new i=0 ; i<num ; i++) {
                Give_Xp(i,20)
        }

However this will give 20 XP multiplied by the amount of people on the team.

Xalus 05-10-2014 14:21

Re: Give experience on roundstart
 
Use player_spawn...

@connoisseur if u dont know shit, shutup.

egbertjan 05-10-2014 14:27

Re: Give experience on roundstart
 
You mean by using:
Code:

RegisterHam(Ham_Spawn,"player","playerSpawn");

public playerSpawn(id)
{
    if(NotFirstSpawn[id])
    {
        /* Code for handling spawn here */
    }
    else
    {
        NotFirstSpawn[id] = true;
    }
}

Could this fully replace my Round_start ?

Code:

register_logevent("RoundStart", 2, "0=World triggered", "1=Round_Start")

EDUTz 05-10-2014 14:49

Re: Give experience on roundstart
 
Code:

for (new i=0; i < 33; i++){
                if(!is_user_bot(i)) {
                RoundExperience(i)
                }
        }


------------>

Code:

for (new i=1; i <= get_maxplayers(); i++){
                if(!is_user_bot(i) && is_user_alive(i)) {
                RoundExperience(i)
                }
        }


egbertjan 05-10-2014 14:53

Re: Give experience on roundstart
 
@EDUTz
Is this a loop to make it easier on the CPU? If so then this could also explain some of my lag issues and in that case I'm thankful if this may solve it!

connoisseur 05-10-2014 14:56

Re: Give experience on roundstart
 
@Xalus There can be more than 1 solution to every problem and mine would work too. Yours sucks by the way.
Did he say he wants to hook spawn? If you hook spawn, players can exploit reconnect to gain more points.
Seems like you're the one who doesn't know shit.
Have a nice day.

NikKOo31 05-10-2014 15:04

Re: Give experience on roundstart
 
Quote:

Originally Posted by egbertjan (Post 2136035)
Actually I tried to do it with this:

Code:

        new players[32], num
        get_players(players,num,"a")       
       
        for(new i=0 ; i<num ; i++) {
                Give_Xp(i,20)
        }

However this will give 20 XP multiplied by the amount of people on the team.

:arrow:
PHP Code:

Give_Xp(players[i],20



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

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