#1

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

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

Please help.
Reply
#2

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];
Reply
#3

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

And what is your problem?
Reply
#5

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.
Reply
#6

My code working, im using in my server
Reply
#7

lol i didn't see TheNerka posting before me..
Reply
#8

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];
Reply
#9

Thanks a-lot.
Reply
#10

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)