GTAOnline.net
San Andreas Multiplayer (sa:mp) => Scripting SA-MP [Pawn center] => Discussion démarrée par: maxya le 10 Août 2013, 15:27:45
-
Salut,
Alors voila un bout de code que j'ai scripter:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/stats", cmdtext, true, 10) == 0)
{
new coordsstring[512];
new mort = PlayerInfo[playerid][pDeaths];
new frags = PlayerInfo[playerid][pKills];
new admin = PlayerInfo[playerid][pAdmin];
new pName[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(coordsstring, sizeof(coordsstring),"----------------------------------- Statistiques de jeu - %s ------------------------------------------",pName);
SendClientMessage(playerid, COLOR_STATS,coordsstring);
format(coordsstring, sizeof(coordsstring), "[Stats:] Frags: [%d] - kill: [%d] - admin level: [%d] ", frags,mort,admin);
SendClientMessage(playerid, COLOR_STATS,coordsstring);
return 1;
}
return 0;
}
Alors j'utilise le système d'enregistrement y_ini qui marche parfaitement, quand PlayerInfo[playerid][pAdmin] = 0 le /stats marche parfaitement mais quand je le change et que je mets n'importe quel autre valeur et que tape /stats sa me mets UNKNOW COMMAND .
Merci d'avance,
Cordialement,
-
Fais voir comment tu charge ou change ton pAdmin
-
je le change manuellement depuis le fichier .ini sinon voila la fonction pour charger le pAdmin:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
}
-
et ton INI_ParseFile tu le met où ?
-
dans OnPlayerConnect
-
donne moi la ligne pour que je vois ce que tu as marqué
et tes WriteInt aussi
-
voila tous le code:
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Connection",""COL_WHITE"Veuillez entrer votre mot de passe pour vous connecter.","Connexion","Quitter");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_Close(File);
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Enregistrement",""COL_RED"Vous avez entré un mot de passe invalide\n"COL_WHITE"Entrer un mot de passe afin de vous enregistrer.","S'enregistrer","Quitter");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_Close(File);
}
}
}
return 1;
}
-
up svp aidez-moi !
-
up je reprends le pawno merci de m'aidé :)
-
if (strcmp("/stats", cmdtext, true, 10) == 0)
{
new String[512];
new pName[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, sizeof(pName), pName);
format(String, sizeof(String),"Statistiques de jeu - %s",pName);
SendClientMessage(playerid, COLOR_STATS, String);
format(String, sizeof(String), "[Statistiques : ] Frags: [%d] - Kills : [%d] - ADM: [%d] ", PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pAdmin]);
SendClientMessage(playerid, COLOR_STATS, String);
return 1;
}
GetPlayerName(playerid, pName, MAX_PLAYER_NAME); // qui, taille, dans quelle variable le mettre.
-
Son code était juste.
Prototype :
GetPlayerName(playerid, const name[], len);
-
Non sa marche toujours pas voila mon code:
if (strcmp("/stats", cmdtext, true, 10) == 0)
{
new coordsstring[512];
new mort = PlayerInfo[playerid][pDeaths];
new frags = PlayerInfo[playerid][pKills];
new admin = PlayerInfo[playerid][pAdmin];
new pName[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, pName, sizeof(pName));
format(coordsstring, sizeof(coordsstring),"----------------------------------- Statistiques de jeu - %s ------------------------------------------",pName);
SendClientMessage(playerid, COLOR_STATS,coordsstring);
format(coordsstring, sizeof(coordsstring), "[Stats:] Frags: [%d] - kill: [%d] - admin level: [%d] ", frags,mort,admin);
SendClientMessage(playerid, COLOR_STATS,coordsstring);
return 1;
}
-
Pourquoi ce " +1 " après MAX_PLAYER_NAME ???
Pour moi, je ferai comme ceci:
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
Et ça, ça fonctionne. À moins que je n'ai pas saisi le problème ...?
-
C'est pour le caractère de fin de chaîne, \0, j'imagine. MAX_PLAYER_NAME ne le prend sans-doute pas en compte. :wink:
-
le problème c'est quand je fais /stats j'ai unknow command et j'ai oublier pourquoi je dois mettre le +1 devant MAX_PLAYER_NAME car sa fais longtemps que j'ai pas toucher au pawn mais je me rappelle qu'il faut le faire .
PS: j'ai essayer sans le +1 mais sa marche pas :/ .
-
if (strcmp("/stats", cmdtext, true, 10) == 0) remplace par if(strcmp(cmdtext, "/stats", true, 6)).
-
je ne comprends plus sa ne marche toujours pas .