їComo hago un cmd con varias opciones? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: Non-English (
https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (
https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Español/Spanish (
https://sampforum.blast.hk/forumdisplay.php?fid=29)
+---- Thread: їComo hago un cmd con varias opciones? (
/showthread.php?tid=528263)
їComo hago un cmd con varias opciones? -
JeffreyG - 27.07.2014
Bueno, quiero hacer un comando que sea asi por ejemplo: /abrir casa /abrir vehiculo /abrir puerta
Osea, con varias opciones, que no tenga que ser /abrircasa sino con espacios y opciones, eso solo lo puse como ejemplo.
Respuesta: їComo hago un cmd con varias opciones? -
BecksLennon - 27.07.2014
Seria asi si es lo que quieres, tu luego lo perfecionas.
pawn Код:
CMD:abrir(playerid, params[])
{
if(IsPlayerConnected(playerid))
{
new x_nr[86];
x_nr = strtok(cmdtext, idx);
if(!strlen(x_nr))
{
SendClientMessage(playerid, TU_COLOR, "/Abrir [/Abrir item]");
SendClientMessage(playerid, TU_COLOR, "Casa, Vehiculo, Puerta");
return 1;
}
if(strcmp(x_nr,"Casa",true) == 0)
{
//Tu funcion etc.
return 1;
}
else if(strcmp(x_nr,"Vehiculo",true) == 0)
//Tu funcion etc.
return 1;
}
else if(strcmp(x_nr,"Puerta",true) == 0)
{
//Tu funcion etc.
return 1;
}
Respuesta: їComo hago un cmd con varias opciones? -
OTACON - 27.07.2014
pawn Код:
#include <a_samp> // => http://sa-mp.com/download.php#include <zcmd> // => forum.sa-mp.com/showthread.php?t=91354#include <sscanf2> // => https://sampforum.blast.hk/showthread.php?tid=120356#include <YSI\y_stringhash> // => https://sampforum.blast.hk/showthread.php?tid=169354COMMAND:ejemplo
(playerid, params
[]){ new opciones
[20];
if(sscanf
(params,
"s[20]", opciones
)) return SendClientMessage
(playerid,
-1,
"escribe el comando /ejemplo [opciones (texto1-texto2-texto3-texto4)] ");
switch (YHash
(opciones
)){ case _H
<texto1
>:{//opcion 1 //tu funcion... } case _H
<texto2
>:{//opcion 2 //tu funcion... } case _H
<texto3
>:{//opcion 3 //tu funcion... } case _H
<texto4
>:{//opcion 4 //tu funcion... } default:{//ninguna opcion //tu funcion... } } return true;
}
Re: Respuesta: їComo hago un cmd con varias opciones? -
zSuYaNw - 28.07.2014
Quote:
Originally Posted by OTACON
pawn Код:
#include <a_samp> // => http://sa-mp.com/download.php#include <zcmd> // => forum.sa-mp.com/showthread.php?t=91354#include <sscanf2> // => https://sampforum.blast.hk/showthread.php?tid=120356#include <YSI\y_stringhash> // => https://sampforum.blast.hk/showthread.php?tid=169354COMMAND:ejemplo (playerid, params []){ new opciones [20]; if(sscanf (params, "s[20]", opciones )) return SendClientMessage (playerid, -1, "escribe el comando /ejemplo [opciones (troll-spammer-molesto-EnzoMetlc)] "); switch (YHash (opciones )){ case _H <troll >:{//opcion 1 //tu funcion... } case _H <spammer >:{//opcion 2 //tu funcion... } case _H <molesto >:{//opcion 3 //tu funcion... } case _H <EnzoMetlc >:{//opcion 4 //tu funcion... } default:{//ninguna opcion //tu funcion... } } return true; }
|
Yook ?
pawn Код:
CMD:abrir(playerid, params[]){
static
opciones[20]
;
if(sscanf(params, "s[20]", opciones)){
return SendClientMessage(playerid, -1, "escribe el comando /abrir <casa, vehiculo, puerta> ");
}
if(!strcmp(opciones, "casa", true)){
// abrir la casa
//
} i
if(!strcmp(opciones, "vehiculo", true)){
// abrir lo vehiculo
//
}
if(!strcmp(opciones, "puerta", true)){
// abrir la puerta
//
}
return true;
}