Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] Help Add

 
  • 0 Vote(s) - 0 Average
Pawn Help Add
Hitler
Offline

Burgershot Member
Posts: 19
Threads: 12
Joined: Feb 2021
Reputation: 0
#1
2021-02-27, 08:57 PM
Español: Hola, tengo un Ranking de equipos en el cual si un jugador mata a otro jugador se le dará +1 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 +1 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?
Programador básico
Virsenas
Offline

Burgershot Member
Posts: 47
Threads: 0
Joined: Feb 2021
Reputation: 6
#2
2021-02-27, 09:02 PM
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?
Hitler
Offline

Burgershot Member
Posts: 19
Threads: 12
Joined: Feb 2021
Reputation: 0
#3
2021-02-27, 09:05 PM
(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 +1 is added
Programador básico
Virsenas
Offline

Burgershot Member
Posts: 47
Threads: 0
Joined: Feb 2021
Reputation: 6
#4
2021-02-27, 09:10 PM
(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 +1 is added

Can you show the loading code?
Hitler
Offline

Burgershot Member
Posts: 19
Threads: 12
Joined: Feb 2021
Reputation: 0
#5
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 +1 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;
}
Programador básico
Virsenas
Offline

Burgershot Member
Posts: 47
Threads: 0
Joined: Feb 2021
Reputation: 6
#6
2021-02-27, 10:42 PM
(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 +1 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 +1 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.
Radical
Offline

Burgershot Member
Posts: 148
Threads: 21
Joined: Dec 2020
Reputation: 16
#7
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'"); 
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode