SA-MP Forums Archive
[Ajuda] Nome em comando - 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: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Nome em comando (/showthread.php?tid=429693)



Nome em comando - WotusPower - 10.04.2013

Como faзo pra apenas o nome %s poder executar o comando? Ex:

/portaocasa 23
-Voce nгo й o %s
-Portao aberto.

?


Re: Nome em comando - ViniBorn - 10.04.2013

Use strcmp


Re: Nome em comando - bruxo00 - 10.04.2013

Sou novato tambйm, se estiver a dizer alguma barbaridade desculpem

Serб que й +/- isto que queres?

PHP код:
#include <zcmd>
CMD:portaocasa23(playeridparams[])
{
    new 
checknome "Nome_Do_Player";
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    if(
name == checknome)
    {
        
// executar o comando que deseja
    
}
    else
    {
        
// Se nгo for o player o que aparece
    
}
    return 
1;




Re: Nome em comando - ViniBorn - 10.04.2013

Quote:
Originally Posted by bruxo00
Посмотреть сообщение
Sou novato tambйm, se estiver a dizer alguma barbaridade desculpem

Serб que й +/- isto que queres?

PHP код:
#include <zcmd>
CMD:portaocasa23(playeridparams[])
{
    new 
checknome "Nome_Do_Player";
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    if(
name == checknome)
    {
        
// executar o comando que deseja
    
}
    else
    {
        
// Se nгo for o player o que aparece
    
}
    return 
1;

Nгo se usa == pra comparar strings
O uso de checknome й desnecessбrio


Re: Nome em comando - Dolby - 10.04.2013

Quote:
Originally Posted by bruxo00
Посмотреть сообщение
Sou novato tambйm, se estiver a dizer alguma barbaridade desculpem

Serб que й +/- isto que queres?

PHP код:
#include <zcmd>
CMD:portaocasa23(playeridparams[])
{
    new 
checknome "Nome_Do_Player";
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    if(
name == checknome)
    {
        
// executar o comando que deseja
    
}
    else
    {
        
// Se nгo for o player o que aparece
    
}
    return 
1;

A lуgica atй que vocк acertou, porйm no Pawn usa-se Strcmp para comprar Strings, e tem que passar quantas cйlulas em uma variбvel do tipo String:
pawn Код:
new checknome[] = "Nome_Do_Player";
Como no exemplo acima vocк nгo informou quantas Cйlulas, ele vai reservar para esta String a quantidade de Cйlulas do valor informado, no caso 15 .


Re: Nome em comando - WotusPower - 10.04.2013

Ainda aguardando ajuda...

Uso strcmp


Re: Nome em comando - Smoking_Script - 12.04.2013

fiz dois codigo tenta aii pra ver espero ter ajudado se poder me dar rep agradeзo

Код:
if (strcmp(cmdtext,"/portaocasa23", true)==0){
new string[256];
new name[30];
GetPlayerName(playerid,name,30);
for(new c; c<MAX_CASAS; c++){
format(string,sizeof(string),"/Casas/casa%d.ini",c);
if(dini_Exists(string)){
if(strcmp(name,dini_Get(string,"Dono"))){
{
format(string, sizeof(string),"Voce nгo й o '%s'", dini_Get(string, "Dono"));
SendClientMessage(playerid, Vermelho, string);
// coloquei aqui a funзao do portao o MoveObject
}
return 1;
} else {
format(string, sizeof(string),"Seja bem vindo Portao aberto '%s'", dini_Get(string, "Dono"));
SendClientMessage(playerid, Verde, string);                        
// coloquei aqui a funзao do portao o MoveObject
}
return 1;
}
}
Код:
if (strcmp(cmdtext,"/portaocasa23", true)==0){
new aname[MAX_PLAYER_NAME];
GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
format(file, sizeof(file), PASTA_CONTAS, aname);
if(strcmp(aname, "nomedacontadele", true) == 0 || strcmp(aname, "nomedacontadele", true) == 0){
//funзao do MoveObject
SendClientMessage(playerid,0x607840AA, "Bem vindo Abrindo o Portгo nome dele.");
return 1;
} else {
SendClientMessage(playerid,Vermelho,"Vocк nao e o nome dele !");
}
return 1;
}