SA-MP Forums Archive
Can anyone pass this command from ZCMD to STRCMP? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Can anyone pass this command from ZCMD to STRCMP? (/showthread.php?tid=653863)



Can anyone pass this command from ZCMD to STRCMP? - leobpo - 15.05.2018

+Rep
Grateful to help

PHP код:
CMD:darcash(playeridparams[])
{
    if(
JogadorInfo[playerid][pAdmin] < 1342 || IsPlayerAdmin(playerid)) return SendClientMessage(playeridiCor_Chat"Vocк nгo й Administrador Dono");
    if(
sscanf(params"dd"iIdSmiriTotalCash)) return SendClientMessage(playeridiCor_Chat"USO: /darcash [ID] [Quantidade]");
    if(!
IsPlayerConnected(iIdSmir)) return SendClientMessage(playeridiCor_Chat"ID Nгo Conectado");
    
GetPlayerName(playeridNomesizeof(Nome));
    
GetPlayerName(iIdSmirNome2sizeof(Nome2));
    
format(iCelulassizeof(iCelulas), "[ iShoppinG ]: %s Deu %d Cash's Para o Jogador %s"NomeiTotalCashNome2);
    
SmirnoffReceberMensagens(COLOR_YELLOW,iCelulas,1);
    
format(iCelulassizeof(iCelulas), "Vocк Recebeu [%d] de Cash do Administrador [%s]"iTotalCashNome);
    
SendClientMessage(iIdSmirCOLOR_LIGHTBLUEiCelulas);
    
JogadorInfo[playerid][pCoins] += iTotalCash;
    
AtualizarCash(iIdSmir);
    return 
1;




Re: Can anyone pass this command from ZCMD to STRCMP? - GTLS - 15.05.2018

PHP код:
if(!strcmp(cmd"/darcash"true)) //Under OnPlayerCommandText

    if(
JogadorInfo[playerid][pAdmin] < 1342 || IsPlayerAdmin(playerid)) return SendClientMessage(playeridiCor_Chat"Vocк nгo й Administrador Dono"); 
    if(
sscanf(params"dd"iIdSmiriTotalCash)) return SendClientMessage(playeridiCor_Chat"USO: /darcash [ID] [Quantidade]"); 
    if(!
IsPlayerConnected(iIdSmir)) return SendClientMessage(playeridiCor_Chat"ID Nгo Conectado"); 
    
GetPlayerName(playeridNomesizeof(Nome)); 
    
GetPlayerName(iIdSmirNome2sizeof(Nome2)); 
    
format(iCelulassizeof(iCelulas), "[ iShoppinG ]: %s Deu %d Cash's Para o Jogador %s"NomeiTotalCashNome2); 
    
SmirnoffReceberMensagens(COLOR_YELLOW,iCelulas,1); 
    
format(iCelulassizeof(iCelulas), "Vocк Recebeu [%d] de Cash do Administrador [%s]"iTotalCashNome); 
    
SendClientMessage(iIdSmirCOLOR_LIGHTBLUEiCelulas); 
    
JogadorInfo[playerid][pCoins] += iTotalCash
    
AtualizarCash(iIdSmir); 
    return 
1

It was literally one line change... and refrain from saying you'll +rep for help cuz people tend not to help sometimes.


Re: Can anyone pass this command from ZCMD to STRCMP? - Sithis - 15.05.2018

Quote:
Originally Posted by GTLS
Посмотреть сообщение
PHP код:
if(!strcmp(cmd"/darcash"true)) //Under OnPlayerCommandText

    if(
JogadorInfo[playerid][pAdmin] < 1342 || IsPlayerAdmin(playerid)) return SendClientMessage(playeridiCor_Chat"Vocк nгo й Administrador Dono"); 
    if(
sscanf(params"dd"iIdSmiriTotalCash)) return SendClientMessage(playeridiCor_Chat"USO: /darcash [ID] [Quantidade]"); 
    if(!
IsPlayerConnected(iIdSmir)) return SendClientMessage(playeridiCor_Chat"ID Nгo Conectado"); 
    
GetPlayerName(playeridNomesizeof(Nome)); 
    
GetPlayerName(iIdSmirNome2sizeof(Nome2)); 
    
format(iCelulassizeof(iCelulas), "[ iShoppinG ]: %s Deu %d Cash's Para o Jogador %s"NomeiTotalCashNome2); 
    
SmirnoffReceberMensagens(COLOR_YELLOW,iCelulas,1); 
    
format(iCelulassizeof(iCelulas), "Vocк Recebeu [%d] de Cash do Administrador [%s]"iTotalCashNome); 
    
SendClientMessage(iIdSmirCOLOR_LIGHTBLUEiCelulas); 
    
JogadorInfo[playerid][pCoins] += iTotalCash
    
AtualizarCash(iIdSmir); 
    return 
1

It was literally one line change... and refrain from saying you'll +rep for help cuz people tend not to help sometimes.
This will not work, since you did not extract any of the command parameters.

To OP: Why even convert to strcmp? It's old, slow and there are much better command processors available, such as ZCMD.


Re: Can anyone pass this command from ZCMD to STRCMP? - CodeStyle175 - 15.05.2018

why would you even want to do that? strcmp is always slower
PHP код:
#include <a_samp>
#include <sscanf2>
uname(pid){
    new 
s[24];
    
GetPlayerName(pid,s,24);
    return 
s;
}
#define scm SendClientMessage
public OnPlayerCommandText(playeridcmdtext[]){
    new 
pid=playerid,cmd[30],p[128],s[128];
    
sscanf(cmdtext"s[30]s[128]"cmdp);
    if(!
strcmp(cmd,"/darcash"true)){
        new 
idamount;
        if(
JogadorInfo[pid][pAdmin] < 1342 && !IsPlayerAdmin(pid)) return scm(pidiCor_Chat"Vocк nгo й Administrador Dono"); 
        if(
sscanf(p,"dd",idamount)) return scm(pidiCor_Chat"USO: /darcash [ID] [Quantidade]"); 
        if(!
IsPlayerConnected(id)) return scm(pidiCor_Chat"ID Nгo Conectado"); 
        
        
format(ssizeof(s), "[ iShoppinG ]: %s Deu %d Cash's Para o Jogador %s"uname(pid), amountuname(id)); 
        
SmirnoffReceberMensagens(COLOR_YELLOW,s,1); 
        
        
format(ssizeof(s), "Vocк Recebeu [%d] de Cash do Administrador [%s]"amountNome); 
        
scm(idCOLOR_LIGHTBLUEs); 
        
        
JogadorInfo[pid][pCoins] += amount
        
AtualizarCash(id);     
    }
    return 
0;