GTAOnline.net

San Andreas Multiplayer (sa:mp) => Scripting SA-MP [Pawn center] => Discussion démarrée par: Wesley9291 le 15 Avril 2012, 14:35:04

Titre: [Résolu] Parti du nom dans une commande.
Posté par: Wesley9291 le 15 Avril 2012, 14:35:04
Bonjour, je voulais savoir ce qui fallait mettre dans une commande pour que quand par exemple je fais /payer [ID] pour pouvoir pas mettre que l'id mais par exemple la partie du nom... Exemple: /payer Name
Titre: Re : [Aide] Parti du nom dans une commande.
Posté par: cristab le 15 Avril 2012, 14:56:03
il y a une fonction sur le wiki retureuserid un truc dans le genre mais c'est pas fiable je trougve
Titre: Re : [Aide] Parti du nom dans une commande.
Posté par: Brian Turner le 15 Avril 2012, 15:03:08
Salut,

il y a la fonction ReturnUser qui se trouve dans l'include gl_common.inc (dossier include a la racine du serveur)

Titre: Re : [Aide] Parti du nom dans une commande.
Posté par: spiirou le 15 Avril 2012, 17:21:07
Soit tu fais ta fonction, soit tu utilise sscanf et en te renseignant tu trouveras ton bonheur
Titre: Re : [Aide] Parti du nom dans une commande.
Posté par: Brian Turner le 15 Avril 2012, 17:42:52
Spiirou la fonction existe deja dans gl_common.inc : http://pastebin.com/22TidrJP (http://pastebin.com/22TidrJP)

Pourquoi la refaire?
Titre: Re : [Aide] Parti du nom dans une commande.
Posté par: Wesley9291 le 16 Avril 2012, 12:43:04
Merci je vais essayer je vous dis si c'est résolu ce soir.
Titre: Re : [Aide] Parti du nom dans une commande.
Posté par: Wesley9291 le 18 Avril 2012, 17:03:42
Pour le sscanf j'ai juste à mettre ça dans le GM ?


stock sscanf(string[], format[], {Float,_}:...)
{
new
formatPos = 0,
stringPos = 0,
paramPos = 2,
paramCount = numargs();
while (paramPos < paramCount && string[stringPos])
{
switch (format[formatPos++])
{
case '\0':
{
return 0;
}
case 'i', 'd':
{
new
neg = 1,
num = 0,
ch = string[stringPos];
if (ch == '-')
{
neg = -1;
ch = string[++stringPos];
}
do
{
stringPos++;
if (ch >= '0' && ch <= '9')
{
num = (num * 10) + (ch - '0');
}
else
{
return 1;
}
}
while ((ch = string[stringPos]) && ch != ' ');
setarg(paramPos, 0, num * neg);
}
case 'h', 'x':
{
new
ch,
num = 0;
while ((ch = string[stringPos++]))
{
switch (ch)
{
case 'x', 'X':
{
num = 0;
continue;
}
case '0' .. '9':
{
num = (num << 4) | (ch - '0');
}
case 'a' .. 'f':
{
num = (num << 4) | (ch - ('a' - 10));
}
case 'A' .. 'F':
{
num = (num << 4) | (ch - ('A' - 10));
}
case ' ':
{
break;
}
default:
{
return 1;
}
}
}
setarg(paramPos, 0, num);
}
case 'c':
{
setarg(paramPos, 0, string[stringPos++]);
}
case 'f':
{
new tmp[25];
strmid(tmp, string, stringPos, stringPos+sizeof(tmp)-2);
setarg(paramPos, 0, _:floatstr(tmp));
}
case 's', 'z':
{
new
i = 0,
ch;
if (format[formatPos])
{
while ((ch = string[stringPos++]) && ch != ' ')
{
setarg(paramPos, i++, ch);
}
if (!i) return 1;
}
else
{
while ((ch = string[stringPos++]))
{
setarg(paramPos, i++, ch);
}
}
stringPos--;
setarg(paramPos, i, '\0');
}
default:
{
continue;
}
}
while (string[stringPos] && string[stringPos] != ' ')
{
stringPos++;
}
while (string[stringPos] == ' ')
{
stringPos++;
}
paramPos++;
}
while (format[formatPos] == 'z') formatPos++;
return format[formatPos];
}


C'est bon sa marche avec le ReturnUser