PDA

View Full Version : Team Score Update Help


eеe
16/12/2011, 02:00 PM
I have got a server which has teams-
TEAM_I
TEAM_U
TEAM_P
TEAM_R
TEAM_U2
i want to make like for example if TEAM_I wins the people of TEAM_I will get 1 score each and that it is saved into a variable so that by typing a cmd people can see which country has how much score...

eеe
16/12/2011, 02:12 PM
help

Tigerkiller
16/12/2011, 02:20 PM
new TeamScoreRed;

if you want to intecrease it do:

TeamScoreRed += value;

for decrease

TeamScoreRed -= value;

[MG]Dimi
16/12/2011, 02:54 PM
UNTESTED:
#include <a_samp>

new TEAM_I_SCORE = 0, TEAM_U_SCORE = 0, TEAM_P_SCORE = 0, TEAM_R_SCORE = 0, TEAM_U2_SCORE = 0;
new gTeam[MAX_PLAYERS];
#define TEAM_I 0
#define TEAM_U 1
#define TEAM_U2 2
#define TEAM_P 3
#define TEAM_R 4

public OnPlayerDeath(playerid,killerid,reason)
{
SetPlayerScore(playerid,GetPlayerScore(playerid)+1 );
switch(gTeam[playerid])/*I guess you used gTeam, if not just change it*/
{
case TEAM_I: TEAM_I_SCORE++;
case TEAM_U: TEAM_U_SCORE++;
case TEAM_P: TEAM_P_SCORE++;
case TEAM_R: TEAM_R_SCORE++;
case TEAM_U2: TEAM_U2_SCORE++;
default: return 1;
}
return 1;
}

public OnPlayerCommandText(playerid,cmdtext[])
{
if(!strcmp(cmdtext,"/teamscore",true))
{
new msg[128];
switch(gTeam[playerid])
{
case TEAM_U: format(msg,128,"Your Team Score: %i",TEAM_U_SCORE);
case TEAM_I: format(msg,128,"Your Team Score: %i",TEAM_I_SCORE);
case TEAM_P: format(msg,128,"Your Team Score: %i",TEAM_P_SCORE);
case TEAM_R: format(msg,128,"Your Team Score: %i",TEAM_R_SCORE);
case TEAM_U2: format(msg,128,"Your Team Score: %i",TEAM_U2_SCORE);
default: return 1;
}
SendClientMessage(playerid,0xFF0000FF,msg);
return 1;
}
return 0;
}

eеe
17/12/2011, 03:00 AM
Dimi;1573759']UNTESTED:
#include <a_samp>

new TEAM_I_SCORE = 0, TEAM_U_SCORE = 0, TEAM_P_SCORE = 0, TEAM_R_SCORE = 0, TEAM_U2_SCORE = 0;
new gTeam[MAX_PLAYERS];
#define TEAM_I 0
#define TEAM_U 1
#define TEAM_U2 2
#define TEAM_P 3
#define TEAM_R 4

public OnPlayerDeath(playerid,killerid,reason)
{
SetPlayerScore(playerid,GetPlayerScore(playerid)+1 );
switch(gTeam[playerid])/*I guess you used gTeam, if not just change it*/
{
case TEAM_I: TEAM_I_SCORE++;
case TEAM_U: TEAM_U_SCORE++;
case TEAM_P: TEAM_P_SCORE++;
case TEAM_R: TEAM_R_SCORE++;
case TEAM_U2: TEAM_U2_SCORE++;
default: return 1;
}
return 1;
}

public OnPlayerCommandText(playerid,cmdtext[])
{
if(!strcmp(cmdtext,"/teamscore",true))
{
new msg[128];
switch(gTeam[playerid])
{
case TEAM_U: format(msg,128,"Your Team Score: %i",TEAM_U_SCORE);
case TEAM_I: format(msg,128,"Your Team Score: %i",TEAM_I_SCORE);
case TEAM_P: format(msg,128,"Your Team Score: %i",TEAM_P_SCORE);
case TEAM_R: format(msg,128,"Your Team Score: %i",TEAM_R_SCORE);
case TEAM_U2: format(msg,128,"Your Team Score: %i",TEAM_U2_SCORE);
default: return 1;
}
SendClientMessage(playerid,0xFF0000FF,msg);
return 1;
}
return 0;
}
Hey man its good but if the server restarts the score will become 0.Please tell hohw to save it and then load it when the server starts again.

Ballu Miaa
17/12/2011, 03:37 AM
To do that you can do two things:
You can use an ini system which I don't recommend that much or you can save the information in a mysql database which is much better and would actually give you the possibility to display the information on a website later on.

Could you please tell us, How can we do it exactly.
We have hosted from volt-host , we got Free MySQL Database there. I've used dini to save it but am not it will save or not.

Can you make a variable of the score's which can be saved and loaded after the restart?

eеe
17/12/2011, 04:00 AM
Hey man read my PM ^^^