SA-MP Forums Archive
Score - 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: Score (/showthread.php?tid=535482)



Score - Biggy54 - 04.09.2014

Hello, I want to make a new score system something like:

2Hour of gameplay = 1 score
1kill=1score
1death= -1 score

Please help.


Re: Score - TheNerka - 04.09.2014

1 hour = 1 score:

Код:
//under OnGameModeInit
SetTimer("gScore",3600000,1);

//Anywhere (out of any callback)
forward gScore();
public gScore()
{
     foreach(Player,i)
     {
          SetPlayerScore(i,GetPlayerScore(i)+1);
     }
     return 1;
}

Not my code
1 kill = score
death = -1 score

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	if(killerid != INVALID_PLAYER_ID)
	{
	    PlayerData[killerid][Kills]++;
	}
	PlayerData[playerid][Deaths]++;
	gIsPlayerDead[playerid] = 1;
	return 1;
}

Need enum

enum pData
{
Kills,
 Deaths,
};
new PlayerData[MAX_PLAYERS][pData];



Re: Score - LeroyII - 04.09.2014

Here is timer system for you, you just have to change timer to give you every hour, not every minute.


Re: Score - JM_Millers - 04.09.2014

And what is your problem?


Re: Score - HazardouS - 04.09.2014

Use these two functions:
https://sampwiki.blast.hk/wiki/SetPlayerScore
https://sampwiki.blast.hk/wiki/GetPlayerScore

Looks like there's an example for giving the killer 1 score.
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    // Add 1 to this killer's score. We must check it is valid first.
    if(killerid != INVALID_PLAYER_ID)
    {
        SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
    }
    return 1;
}
To decrease the score of the victim you can add this line under the "if" statement:
pawn Код:
SetPlayerScore(playerid, GetPlayerScore(playerid) - 1);
Good luck.


Re: Score - TheNerka - 04.09.2014

My code working, im using in my server


Re: Score - LeroyII - 04.09.2014

lol i didn't see TheNerka posting before me..


Re: Score - TheNerka - 04.09.2014

1 hour = 1 score:

Код:
//under OnGameModeInit
SetTimer("gScore",3600000,1);

//Anywhere (out of any callback)
forward gScore();
public gScore()
{
     foreach(Player,i)
     {
          SetPlayerScore(i,GetPlayerScore(i)+1);
     }
     return 1;
}
Not my code
1 kill = score
death = -1 score


Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	if(killerid != INVALID_PLAYER_ID)
	{
	    PlayerData[killerid][Kills]++;
	}
	PlayerData[playerid][Deaths]++;
	return 1;
}

Need enum

enum pData
{
Kills,
 Deaths,
};
new PlayerData[MAX_PLAYERS][pData];



Re: Score - Biggy54 - 04.09.2014

Thanks a-lot.


Re: Score - TheNerka - 04.09.2014

OOPS my kill deaths not got score he show kill and deaths sorry

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	if(killerid != INVALID_PLAYER_ID)
	{
	     SetPlayerScore(killerid, GetPlayerScore(killerid)+1);
	}
	 SetPlayerScore(playerd, GetPlayerScore(playerd)-1);
	return 1;
}