SA-MP Forums Archive
Need help with 1 function. +1 rep for help. - 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)
+--- Thread: Need help with 1 function. +1 rep for help. (/showthread.php?tid=308874)



Need help with 1 function. +1 rep for help. - Artie_Scorpion - 05.01.2012

This is the function

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if (killerid != playerid) {
        if (GetPlayerExpLevel(playerid) < GetPlayerExpLevel(killerid))
        {
            GivePlayerExp(killerid, -15, "Jums dingo 15 exp uz nuzudima!");
        }
        else if (GetPlayerExpLevel(playerid) > GetPlayerExpLevel(killerid))
        {
            GivePlayerExp(killerid, -15, "Jums dingo 15 exp uz nuzudima!");
        }
        else
        {
            GivePlayerExp(killerid, -15, "Jums dingo 15 exp uz nuzudima!");
        }
    }
    return 1;
}
This is a principle of everything.
Ok how to make to get 2 exp per 3 minutes? And i need to make it on score board too...
Well this function called OnPlayerDeath is not necessary


Re: Need help with 1 function. +1 rep for help. - BrandyPenguin - 05.01.2012

Do you want every player 3 minutes by adding 2 or like all in-game players in 3 minutes?


Re: Need help with 1 function. +1 rep for help. - Artie_Scorpion - 05.01.2012

Quote:
Originally Posted by BrandyPenguin
Посмотреть сообщение
Do you want every player 3 minutes by adding 2 or like all in-game players in 3 minutes?
I want to get 1 expierence points (exp) per 3 minutes...


Re: Need help with 1 function. +1 rep for help. - Shoulen - 05.01.2012

This should work, it's not tested though so no guarentees

pawn Код:
forward ExpTimer(); // Forward the timer callback

public ExpTimer() { // The timer callback
for(new i = 0; i < MAX_PLAYERS; i++) { // Loop
if(IsPlayerConnected(playerid)) {
GivePlayerExp(killerid, 3, "+1 EXP"); // Every connected player receives 1 EXP
}
}
}

public OnGameModeInit() {
SetTimer("ExpTimer", 180000, true); // Repeating timer set when the server starts up
}
- Shoulen


Re: Need help with 1 function. +1 rep for help. - [MG]Dimi - 05.01.2012

Quote:
Originally Posted by Shoulen
Посмотреть сообщение
This should work, it's not tested though so no guarentees

pawn Код:
forward ExpTimer(); // Forward the timer callback

public ExpTimer() { // The timer callback
for(new i = 0; i < MAX_PLAYERS; i++) { // Loop
if(IsPlayerConnected(playerid)) {
GivePlayerExp(killerid, 3, "+1 EXP"); // Every connected player receives 1 EXP
}
}
}

public OnGameModeInit() {
SetTimer("ExpTimer", 180000, true); // Repeating timer set when the server starts up
}
- Shoulen
Under IsPlayerConnected(playerid) should be IsPlayerConnected(i)). playerid isn't even defined.


Re: Need help with 1 function. +1 rep for help. - Basssiiie - 05.01.2012

The whole script is causing errors. For example 'killerid' isn't defined either and the script gives the player 3 experience instead of one.

This should be correct:
Код:
forward ExpTimer(); // Forward the timer callback

public ExpTimer()  // The timer callback
{ 
	for(new i = 0; i != MAX_PLAYERS; i++) 
	{ // Loop
		if(IsPlayerConnected(i) && !IsPlayerNPC(i)) // Checks if player is connected + NPC's don't need experience
		{
			GivePlayerExp(i, 1, "+1 EXP"); // Every connected player receives 1 EXP
		}	
	}
	return 1;
}

public OnGameModeInit() 
{
	SetTimer("ExpTimer", 180000, true); // Repeating timer set when the server starts up
}



Re: Need help with 1 function. +1 rep for help. - Artie_Scorpion - 05.01.2012

+1 rep for all who tryed to help me