GTAOnline.net

San Andreas Multiplayer (sa:mp) => Scripting SA-MP [Pawn center] => Discussion démarrée par: leptiroman le 12 Juin 2009, 01:36:58

Titre: [RESOLU]modification commande ?
Posté par: leptiroman le 12 Juin 2009, 01:36:58
Bonsoir,
 cette commande :
  if(strcmp(cmd, "/asay", true) == 0)
    {
    if (PlayerInfo[playerid][pAdmin] >= 1)
    {
      GetPlayerName(playerid, sendername, sizeof(sendername));
        new result[128];
        result = strtok(cmdtext, idx);
        if(!strlen(result))
        {
           SendClientMessage(playerid, COLOR_GREY, "USAGE: /say [message]");
            SendClientMessage(playerid, COLOR_GREY, "FONCTION : transmettra un message admin.");
            return 1;
        }
        format(string, sizeof(string), " Modo: %s", result);
        SendClientMessageToAll(COLOR_LIGHTRED, string);
        printf("%s", string);
        }
        else
        {
         SendClientMessage(playerid,COLOR_GREY, "Vous n'avez pas un le admin requis.");
            return 1;
      }
}

c'est un  /asay admin a partir de admin 1 on peu l'utiliser

j'aimerai modifier cette commande de façon a ce que; par exemple lvl admin 1 ça donne une couleur
 lvl admin 1 ça donne une couleur diffèrente etc.

Mais si je les met l'un a la suite de l'autre je me met en admin 4 ma couleur reste inchangée,

Comment je dot faire pour qu'un commande ne sois accessible que a un lvl admin précis. et pas a partir de ce lvl?

ou bien comment faire pour que quand admin 1 parle c'est une couleur
admin 2 parle un autre couleur etc.
Titre: Re : modification commande ?
Posté par: ghm94 le 12 Juin 2009, 02:53:29
Salut,

En mettant des :
if (PlayerInfo[playerid][pAdmin] == *)
* correspond au niveau admin. Sa ve dire que si tu met :
if (PlayerInfo[playerid][pAdmin] == 2)
{
/* ton code Ici */
}

Tout ce qui se trouveras entre les accolades s'executra si le joueur est admin lvl 2

Sa ve dire que dans le code que tu à donner, les instruction s'exécute si tu est admin lvl 1 ou plus.

J'éspère t'avoir aider.

++ghm
Titre: Re : modification commande ?
Posté par: HackMaite le 12 Juin 2009, 05:15:36
Peut tu envoyer entièrement ton code s'il te plait?

Je cherchais ce script..

Merci.
Titre: Re : modification commande ?
Posté par: leptiroman le 12 Juin 2009, 12:46:12
c'est justement mon problème

ça s'applique si tu est admin lvl 1 ou plus

moi je veux que ça s'applique si je suis admin 1 UNIQUEMENT, pas si je suis admin 2 ou plus, Uniquement admin 1 vu que je compte mettre le meme pour admin 2 avec une aurte couleur,....


ps : HackMaite (le code est en entier là suffi de l'interégré a ton GM il fonctionne) 
Titre: Re : modification commande ?
Posté par: ghm94 le 12 Juin 2009, 14:02:25
Dans ce cas la change :
if (PlayerInfo[playerid][pAdmin] >= 1)par :
if (PlayerInfo[playerid][pAdmin] == 1)
Dit moi si sa marche.

++
Titre: Re : modification commande ?
Posté par: leptiroman le 12 Juin 2009, 16:10:15
Super merci ghm94 ça marche, mais quasiment lol

si je fait

Citer
if(strcmp(cmd, "/asay", true) == 0)
    {
    if (PlayerInfo[playerid][pAdmin] == 1)
    {
      GetPlayerName(playerid, sendername, sizeof(sendername));
        new result[128];
        result = strtok(cmdtext, idx);
        if(!strlen(result))
        {
           SendClientMessage(playerid, COLOR_GREY, "USAGE: /say [message]");
            SendClientMessage(playerid, COLOR_GREY, "FONCTION : transmettra un message admin.");
            return 1;
        }
        format(string, sizeof(string), " Modo: %s", result);
        SendClientMessageToAll(COLOR_LIGHTRED, string);
        printf("%s", string);
        }
        else
        {
         SendClientMessage(playerid,COLOR_GREY, "Vous n'avez pas un le admin requis.");
            return 1;
      }
}
suivit de
Citer
if(strcmp(cmd, "/asay", true) == 0)
    {
    if (PlayerInfo[playerid][pAdmin] µ== 2)
    {
      GetPlayerName(playerid, sendername, sizeof(sendername));
        new result[128];
        result = strtok(cmdtext, idx);
        if(!strlen(result))
        {
           SendClientMessage(playerid, COLOR_GREY, "USAGE: /say [message]");
            SendClientMessage(playerid, COLOR_GREY, "FONCTION : transmettra un message admin.");
            return 1;
        }
        format(string, sizeof(string), " Admin: %s", result);
        SendClientMessageToAll(COLOR_LIGHTRED, string);
        printf("%s", string);
        }
        else
        {
         SendClientMessage(playerid,COLOR_GREY, "Vous n'avez pas un le admin requis.");
            return 1;
      }
}

du coup le /asay marche plus por les lvl supérieur,...

logique tu va me dire mais mon but c'ets que le asay our un grade admin donne X et pour un autre donne Y tu vois, mais avec la même commande tu vois  qcue je vx dire?
Titre: Re : modification commande ?
Posté par: ghm94 le 12 Juin 2009, 16:21:08
Dans ce cas la tu devrait tous mettre dans une seule commande comme ceci :

if(strcmp(cmd, "/asay", true) == 0)
{
    if (PlayerInfo[playerid][pAdmin] == 1)
    {
        GetPlayerName(playerid, sendername, sizeof(sendername));
        new result[128];
        result = strtok(cmdtext, idx);
        if(!strlen(result))
        {
            SendClientMessage(playerid, COLOR_GREY, "USAGE: /say [message]");
            SendClientMessage(playerid, COLOR_GREY, "FONCTION : transmettra un message admin.");
            return 1;
        }
        format(string, sizeof(string), " Modo: %s", result);
        SendClientMessageToAll(COLOR_LIGHTRED, string);
        printf("%s", string);
    }
    else if (PlayerInfo[playerid][pAdmin] == 2)
    {
        GetPlayerName(playerid, sendername, sizeof(sendername));
        new result[128];
        result = strtok(cmdtext, idx);
        if(!strlen(result))
        {
            SendClientMessage(playerid, COLOR_GREY, "USAGE: /say [message]");
            SendClientMessage(playerid, COLOR_GREY, "FONCTION : transmettra un message admin.");
            return 1;
        }
        format(string, sizeof(string), " Admin: %s", result);
        SendClientMessageToAll(COLOR_LIGHTRED, string);
        printf("%s", string);
    }
    else
    {
        SendClientMessage(playerid,COLOR_GREY, "Vous n'avez pas un lvl admin requis.");
        return 1;
    }
}

Après tu peut rajouter autant de  else if() que tu veut....
Titre: Re : modification commande ?
Posté par: leptiroman le 12 Juin 2009, 16:48:02
aaaa okkk merci bcp ! je test ça tt de suite !

 :cheers

Double post
aaaa okkk merci bcp ! je test ça tt de suite !

 :cheers

EDITH: PARFAIT! merci bcp ghm94  !
Titre: Re : modification commande ?
Posté par: cristab le 12 Juin 2009, 17:18:45
je precise juste qu'il vaut mieux revoir le code 

Ps peu etre des erreure je les coder directement sur la reponse donc dur dur

if(strcmp(cmd, "/asay", true) == 0)
{
    if (PlayerInfo[playerid][pAdmin] == 0)
        {
            SendClienMessage(playerid,COLOR_RED,"commande reservé.");
            return 1;
        }
   
        GetPlayerName(playerid, sendername, sizeof(sendername));
        new result[128];
        result = strtok(cmdtext, idx);
        if(!strlen(result))
        {
            SendClientMessage(playerid, COLOR_GREY, "USAGE: /say [message]");
            SendClientMessage(playerid, COLOR_GREY, "FONCTION : transmettra un message admin.");
            return 1;
        }
        if (PlayerInfo[playerid][pAdmin] == 1){
        format(string, sizeof(string), " Modo: %s", result);
        SendClientMessageToAll(COLOR_LIGHTRED, string);
        printf("MODO %s:%s",sendername, string);
    }
    else if (PlayerInfo[playerid][pAdmin] == 2)
    {
       
        format(string, sizeof(string), " Admin: %s", result);
        SendClientMessageToAll(COLOR_LIGHTRED, string);
        printf("Admin %s: %s",sendername, string);
    }
    return 1;
}
Titre: Re : modification commande ?
Posté par: ghm94 le 12 Juin 2009, 17:21:18
De rien  :) et pour ton code Cristab c'est mieux car sa prend moins de place mais sinon sa revient à la même chose.

++ghm
Titre: Re : modification commande ?
Posté par: leptiroman le 12 Juin 2009, 20:24:21
merci à vous tous :)

Double post
heu encor un probleme si j'utilise la cmd

/asay bonjour à tous

ça marquera juste le bonjour

ça ne met juste un mot  :( :( :(
Titre: Re : modification commande ?
Posté par: S!m le 13 Juin 2009, 00:59:48
Salut,

c'est que tu utilise un strtok pour récupérer le paramètre, or strtok ne retourne qu'un seul mot, donc:

if(strcmp(cmd, "/asay", true) == 0)
{
    if (PlayerInfo[playerid][pAdmin] == 0)
        {
            SendClienMessage(playerid,COLOR_RED,"commande reservé.");
            return 1;
        }
   
        GetPlayerName(playerid, sendername, sizeof(sendername));
        if(!strlen(result))
        {
            SendClientMessage(playerid, COLOR_GREY, "USAGE: /say [message]");
            SendClientMessage(playerid, COLOR_GREY, "FONCTION : transmettra un message admin.");
            return 1;
        }
        if (PlayerInfo[playerid][pAdmin] == 1){
        format(string, sizeof(string), " Modo: %s", cmdtext[6]);
        SendClientMessageToAll(COLOR_LIGHTRED, string);
        printf("MODO %s:%s",sendername, string);
    }
    else if (PlayerInfo[playerid][pAdmin] == 2)
    {
       
        format(string, sizeof(string), " Admin: %s", cmdtext[6]);
        SendClientMessageToAll(COLOR_LIGHTRED, string);
        printf("Admin %s: %s",sendername, string);
    }
    return 1;
}
remarque la différence afin de bien comprendre

++Sim++
Titre: Re : modification commande ?
Posté par: leptiroman le 13 Juin 2009, 01:22:28
ok donc la difference est que tu a ebnlever le

new result[128];
    result = strtok(cmdtext, idx);

et transform le
format(string, sizeof(string), " Modo: %s ", result);
en

format(string, sizeof(string), " Modo: %s", cmdtext[6])
c'est bien ça?

EDITH
mais avec ton code il me t met une erreur
Citer
(...) \le ptiroman\gamemodes\LePtiRomand.pwn(13611) : error 017: undefined symbol "result"

   if(strcmp(cmd, "/asay", true) == 0)
{
    if (PlayerInfo[playerid][pAdmin] == 0)
        {
            SendClientMessage(playerid,COLOR_RED,"commande reservé.");
            return 1;
        }

        GetPlayerName(playerid, sendername, sizeof(sendername));
        if(!strlen(result))
        {
            SendClientMessage(playerid, COLOR_GREY, "USAGE: /asay [message]");
            SendClientMessage(playerid, COLOR_GREY, "FONCTION : transmettra un message admin.");
            return 1;
        }
Titre: Re : modification commande ?
Posté par: MrFredo le 13 Juin 2009, 01:29:26
petite correction faudrait remplacer if(!strlen(result)) par if(!strlen(cmdtext[idx]))


Et aussi je remplacerai les cmdtext[6] par cmdtext[idx] perso comme sa pas besoin de te faire chiez a recompter les lettre si un jour tu change le nom de ta cmd

vu que le idx est retourner apres l'apel a strtok tout au debut de ta callback
Titre: Re : modification commande ?
Posté par: leptiroman le 13 Juin 2009, 01:31:05
a ool bah voila 'tas corriger l'erreur avent de lire mon EDITH MDR

merci bcp !
Titre: Re : modification commande ?
Posté par: S!m le 13 Juin 2009, 01:55:55
Salut,

mais certains GM n'ont pas cet appel a strtok...et une constante est toujours plus rapide qu'une variable (de très peu)
bref, très bon mais certaines exceptions

++Sim++
Titre: Re : modification commande ?
Posté par: leptiroman le 13 Juin 2009, 17:51:04
En tout cas merci a vous tous de m'aider :)