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

Titre: Code qui marche pas
Posté 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,
Titre: Re : Code qui marche pas
Posté par: Garwan50 le 10 Août 2013, 15:36:53
Fais voir comment tu charge ou change ton pAdmin
Titre: Re : Code qui marche pas
Posté par: maxya le 10 Août 2013, 15:44:47
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]);
}
Titre: Re : Code qui marche pas
Posté par: Garwan50 le 10 Août 2013, 16:52:01
et ton INI_ParseFile tu le met où ?
Titre: Re : Code qui marche pas
Posté par: maxya le 10 Août 2013, 17:09:10
dans OnPlayerConnect
Titre: Re : Code qui marche pas
Posté par: Garwan50 le 10 Août 2013, 17:18:34
donne moi la ligne pour que je vois ce que tu as marqué

et tes WriteInt aussi
Titre: Re : Code qui marche pas
Posté par: maxya le 10 Août 2013, 21:27:53
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;
}
Titre: Re : Code qui marche pas
Posté par: maxya le 23 Août 2013, 13:21:42
up svp aidez-moi !
Titre: Re : Code qui marche pas
Posté par: maxya le 22 Novembre 2013, 19:13:17
up je reprends le pawno merci de m'aidé :)
Titre: Re : Code qui marche pas
Posté par: Xolokos le 23 Novembre 2013, 12:57:35
Code: (PAWN) [Sélectionner]
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;
}

Code: (PAWN) [Sélectionner]
GetPlayerName(playerid, pName, MAX_PLAYER_NAME); // qui, taille, dans quelle variable le mettre.
Titre: Re : Code qui marche pas
Posté par: vincentdu90 le 23 Novembre 2013, 14:29:02
Son code était juste.

Prototype :
Code: (Pawn) [Sélectionner]
GetPlayerName(playerid, const name[], len);
Titre: Re : Code qui marche pas
Posté par: maxya le 23 Novembre 2013, 20:01:36
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;
}
Titre: Re : Code qui marche pas
Posté par: Infu le 23 Novembre 2013, 22:05:47
Pourquoi ce " +1 " après MAX_PLAYER_NAME ???
Pour moi, je ferai comme ceci:


Code: (pawn) [Sélectionner]
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 ...?
Titre: Re : Code qui marche pas
Posté par: Gzsume le 23 Novembre 2013, 22:34:01
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:
Titre: Re : Code qui marche pas
Posté par: maxya le 23 Novembre 2013, 22:34:23
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 :/ .
Titre: Re : Code qui marche pas
Posté par: jerem428 le 24 Novembre 2013, 02:15:05
if (strcmp("/stats", cmdtext, true, 10) == 0) remplace par  if(strcmp(cmdtext, "/stats", true, 6)).
Titre: Re : Code qui marche pas
Posté par: maxya le 24 Novembre 2013, 19:07:41
je ne comprends plus sa ne marche toujours pas .