Espa?ol: Hola, tengo un Ranking de equipos en el cual si un jugador mata a otro jugador se le dar? de puntaje?al team, el problema es que cuando reinicio el servidor cuando?un jugador mata a otro jugador la puntuaci?n del team vuelve a 1 y va sumando nuevamente, en la base de datos se?guarda bien el puntaje del team pero se pierde cuando se suma nuevamente, debe ser por esta funci?n que quiz?s est? mal.
English: Hello, I have a Team Ranking in which if a player kills another player, the team will be given score, the problem is that when I restart the server when a player kills another player, the team score returns to 1 and it is adding again, in the database the team's score is saved well but it is lost when it is added again, it must be because of this function that it may be wrong.
Code: new query[250],puntaje;
puntaje?= 1;
mysql_format(con, query, sizeof query, "UPDATE `Ranking` SET `Score` = '%d' WHERE `ID` = '1'", puntaje);
mysql_query(con, query);
Espa?ol:?O cual ser?a la soluci?n?
English:?Or what would be the solution?
Quote:the problem is that when I restart the server when a player kills another player, the team score returns to 1 and it is adding again
Sounds like a loading problem. Did you debug the loading? Did you check what it loads?
(2021-02-27, 09:02 PM)Virsenas Wrote: Quote:the problem is that when I restart the server when a player kills another player, the team score returns to 1 and it is adding again
Sounds like a loading problem. Did you debug the loading? Did you check what it loads?
It loads well, the problem is when is added
(2021-02-27, 09:05 PM)Hitler Wrote: (2021-02-27, 09:02 PM)Virsenas Wrote: Quote:the problem is that when I restart the server when a player kills another player, the team score returns to 1 and it is adding again
Sounds like a loading problem. Did you debug the loading? Did you check what it loads?
It loads well, the problem is when is added
Can you show the loading code?
2021-02-27, 09:28 PM
(This post was last modified: 2021-02-27, 09:31 PM by Hitler.)
(2021-02-27, 09:10 PM)Virsenas Wrote: (2021-02-27, 09:05 PM)Hitler Wrote: (2021-02-27, 09:02 PM)Virsenas Wrote: Quote:the problem is that when I restart the server when a player kills another player, the team score returns to 1 and it is adding again
Sounds like a loading problem. Did you debug the loading? Did you check what it loads?
It loads well, the problem is when is added
Can you show the loading code?
Code: CMD:ranking(playerid)
{
mysql_pquery(con, "SELECT `Team`, `Score` FROM `Ranking` WHERE `Score` > 0 ORDER BY `Score` DESC LIMIT 4", "Rank", "d", playerid);
return 1;
}
funcion Rank(playerid)
{
new rows = cache_num_rows(), prueba[300], Escore, team[MAX_PLAYER_NAME];
if(rows > 0)
{
prueba = "{FFFFFF}Ranking Teams\n\n";
for (new i = 0; i < rows; i)
{
cache_get_value_name_int(i, "Score", Escore);
cache_get_value_name(i, "Team", team, MAX_PLAYER_NAME);
format(prueba, sizeof(prueba), "%s#%d %s? ? %d\n", prueba, i 1, team, Escore);
}
ShowPlayerDialog(playerid, 777, DIALOG_STYLE_MSGBOX, "Ranking Teams", prueba, "Cerrar", "");
}
return 1;
}
(2021-02-27, 09:28 PM)Hitler Wrote: (2021-02-27, 09:10 PM)Virsenas Wrote: (2021-02-27, 09:05 PM)Hitler Wrote: (2021-02-27, 09:02 PM)Virsenas Wrote: Quote:the problem is that when I restart the server when a player kills another player, the team score returns to 1 and it is adding again
Sounds like a loading problem. Did you debug the loading? Did you check what it loads?
It loads well, the problem is when is added
Can you show the loading code?
Code: CMD:ranking(playerid)
{
mysql_pquery(con, "SELECT `Team`, `Score` FROM `Ranking` WHERE `Score` > 0 ORDER BY `Score` DESC LIMIT 4", "Rank", "d", playerid);
return 1;
}
funcion Rank(playerid)
{
new rows = cache_num_rows(), prueba[300], Escore, team[MAX_PLAYER_NAME];
if(rows > 0)
{
prueba = "{FFFFFF}Ranking Teams\n\n";
for (new i = 0; i < rows; i)
{
cache_get_value_name_int(i, "Score", Escore);
cache_get_value_name(i, "Team", team, MAX_PLAYER_NAME);
format(prueba, sizeof(prueba), "%s#%d %s? ? %d\n", prueba, i 1, team, Escore);
}
ShowPlayerDialog(playerid, 777, DIALOG_STYLE_MSGBOX, "Ranking Teams", prueba, "Cerrar", "");
}
return 1;
}
Quote:It loads well, the problem is when is added
I would be surprised if the code even compiled. You just created that code with no real care just to make it look like you tried putting in effort. I wondered why it took you more than 10 minutes to copy and paste your loading code.
In order to make your ranking script you will need:
https://www.youtube.com/watch?v=kR3nRkbGmiA for information to hold (team names, player names, score etc.)
https://sampwiki.blast.hk/wiki/MySQL/R40 for loading and saving
https://open.mp/docs/scripting/functions/strcat for showing ranking information in a dialog
Good luck.
2021-02-27, 11:28 PM
(This post was last modified: 2021-02-27, 11:29 PM by Radical.)
PHP Code: mysql_tquery(con, "UPDATE `Ranking` SET `Score` = `Score` 1 WHERE `ID` = '1'");
|