SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 19/05/2019, 03:21 PM   #1
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 203
Reputation: 6
Default How to force a command in zcmd

PHP Code:
else if(dialogid == 402) {
        new 
id whogiveoffer[playerid];
        new 
quantidade strval(inputtext);
        return 
cmd_pay(playerididquantidade);

This line is give an error:
PHP Code:
return cmd_pay(playerididquantidade); 
PHP Code:
error 035argument type mismatch (argument 2

The command code is:
PHP Code:
CMD:pay(playeridparams[]) {
    if(
Logado[playerid] == 0) return 0;
    new 
idquantidadestring[128];
    if(
sscanf(params,"ui"idquantidade)) return SendClientMessage(playerid, -1"Use: /pay [id] [ammount]");
    if(
GetPlayerMoneyEx(playerid) < quantidade) return SendClientMessage(playerid, -1"You don't have this money!");
    if(
playerid == id) return SendClientMessage(playerid, -1"You can't use this command for yourself");
    if(
GetPlayerLevel(playerid"lvl") < 2) return SendClientMessage(playerid, -1"You need to be level 2 or higher");
    if(
id != INVALID_PLAYER_ID) {
        if(
morto[playerid] > 0) return SendClientMessage(playeridCOLOR_RED"You can not use this command killed.");
        new 
Float:Pos[3];
        
GetPlayerPos(idPos[0], Pos[1], Pos[2]);
        if(
IsPlayerInRangeOfPoint(playerid5.0Pos[0], Pos[1], Pos[2])) {
            
format(stringsizeof(string), " %s paid %i$ to %s."PlayerName(playerid), quantidadePlayerName(id));
            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            
GivePlayerMoneyEx(idquantidade);
            
GivePlayerMoneyEx(playerid, -quantidade);
            
PlayerPlaySound(playerid10520.00.00.0);
            
PlayerPlaySound(id10520.00.00.0);
        }
    }
    return 
1;

binnyl is offline   Reply With Quote
Old 19/05/2019, 03:54 PM   #2
Mobtiesgangsa
Big Clucker
 
Join Date: Oct 2016
Posts: 128
Reputation: 16
Default Re: How to force a command in zcmd

Turn this

PHP Code:
cmd_pay(playerididquantidade); 
into

PHP Code:
cmd_pay(playeridquantidade); 
Mobtiesgangsa is offline   Reply With Quote
Old 19/05/2019, 05:48 PM   #3
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 203
Reputation: 6
Default Re: How to force a command in zcmd

Quote:
Originally Posted by Mobtiesgangsa View Post
Turn this

PHP Code:
cmd_pay(playerididquantidade); 
into

PHP Code:
cmd_pay(playeridquantidade); 
I have to pass id as parameter too
quantidade is the ammount and id is the player who will recive the money
binnyl is offline   Reply With Quote
Old 19/05/2019, 06:27 PM   #4
Koreadars
Big Clucker
 
Join Date: Mar 2019
Location: Czech Republic, Prdelákov.
Posts: 127
Reputation: 6
Default Re: How to force a command in zcmd

I think this one should work.
pawn Code:
CallLocalFunction("cmd_pay", "ii", id, quantidade);
Koreadars is offline   Reply With Quote
Old 21/05/2019, 04:24 AM   #5
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 203
Reputation: 6
Default Re: How to force a command in zcmd

Quote:
Originally Posted by Koreadars View Post
I think this one should work.
pawn Code:
CallLocalFunction("cmd_pay", "ii", id, quantidade);

Works, ty +rep

---

EDIT:

It's not working, its calling the function, but not giving the right parameters...

When i send:
Code:
    else if(dialogid == 402) {
        if(!response) return 1;
        if(!strlen(inputtext) || !IsNumeric(inputtext)) return SendClientMessage(playerid, -1, "Choose a valid ID!");
        new id = whogiveoffer[playerid];
        new quantidade = strval(inputtext);
        CallLocalFunction("cmd_pay", "iii", playerid, id, quantidade);
    }
It's returning on:
Code:
if(sscanf(params,"ui", id, quantidade)) return SendClientMessage(playerid, -1, "Use: /pay [id] [ammount]");
from
Code:
CMD:pay(playerid, params[]) {
    if(Logado[playerid] == 0) return 0;
    new id, quantidade, string[128];
    if(sscanf(params,"ui", id, quantidade)) return SendClientMessage(playerid, -1, "Use: /pay [id] [ammount]");
    if(GetPlayerMoneyEx(playerid) < quantidade) return SendClientMessage(playerid, -1, "You don't have this money!");
    if(playerid == id) return SendClientMessage(playerid, -1, "You can't use this command for yourself");
    if(GetPlayerLevel(playerid, "lvl") < 2) return SendClientMessage(playerid, -1, "You need to be level 2 or higher");
    if(id != INVALID_PLAYER_ID) {
        if(morto[playerid] > 0) return SendClientMessage(playerid, COLOR_RED, "You can not use this command killed.");
        new Float:Pos[3];
        GetPlayerPos(id, Pos[0], Pos[1], Pos[2]);
        if(IsPlayerInRangeOfPoint(playerid, 5.0, Pos[0], Pos[1], Pos[2])) {
            format(string, sizeof(string), " %s paid %i$ to %s.", PlayerName(playerid), quantidade, PlayerName(id));
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            GivePlayerMoneyEx(id, quantidade);
            GivePlayerMoneyEx(playerid, -quantidade);
            PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
            PlayerPlaySound(id, 1052, 0.0, 0.0, 0.0);
        }
    }
    return 1;
}

Last edited by binnyl; 21/05/2019 at 11:19 AM.
binnyl is offline   Reply With Quote
Old 21/05/2019, 11:19 AM   #6
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 203
Reputation: 6
Default Re: How to force a command in zcmd

EDIT, it's not working!
binnyl is offline   Reply With Quote
Old 21/05/2019, 11:38 AM   #7
Koreadars
Big Clucker
 
Join Date: Mar 2019
Location: Czech Republic, Prdelákov.
Posts: 127
Reputation: 6
Default Re: How to force a command in zcmd

pawn Code:
CallLocalFunction("cmd_pay", "ii", id, quantidade);
Koreadars is offline   Reply With Quote
Old 21/05/2019, 11:55 AM   #8
cSharp
Big Clucker
 
Join Date: Oct 2018
Posts: 82
Reputation: 27
Default Re: How to force a command in zcmd

That's not how it works guys...

new parameters[11+1+11+1];
format(parameters, sizeof parameters, "%i %i", id, quantidade);
cmd_pay(playerid, parameters);

The function only allows 2 parameters, player id executing the command and the follow-up parameters as a string. There's a reason you're using sscanf, is there not?
cSharp is offline   Reply With Quote
Old 22/05/2019, 04:31 PM   #9
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 203
Reputation: 6
Default Re: How to force a command in zcmd

Quote:
Originally Posted by cSharp View Post
That's not how it works guys...

new parameters[11+1+11+1];
format(parameters, sizeof parameters, "%i %i", id, quantidade);
cmd_pay(playerid, parameters);

The function only allows 2 parameters, player id executing the command and the follow-up parameters as a string. There's a reason you're using sscanf, is there not?
It not work bro
I send 500$ to ID 1 but para print 49

print
Code:
[12:29:50] PARA: 49
[12:29:50] pay 1
[12:29:50] pay 2
[12:29:50] pay 3
[12:29:50] pay 4
[12:29:50] pay 5
PHP Code:
ShowPlayerDialog(playerid401DIALOG_STYLE_INPUT"Who Give Money""Set how much money you want to give.""Set""Cancel");
...
    else if(
dialogid == 401) {
        if(!
response) return 1;
        if(!
strlen(inputtext) || !IsNumeric(inputtext)) return SendClientMessage(playerid, -1"Choose a valid ID!");
        
whogiveoffer[playerid] = strval(inputtext);
        
ShowPlayerDialog(playerid402DIALOG_STYLE_INPUT"How much money""Put here how much money you want to give""Set""Cancel");  
    }
    else if(
dialogid == 402) {
        if(!
response) return 1;
        if(!
strlen(inputtext) || !IsNumeric(inputtext)) return SendClientMessage(playerid, -1"Choose a valid ID!");
        new 
id whogiveoffer[playerid];
        new 
quantidade strval(inputtext);
        new 
parameters[11+1+11+1];
        
format(parameterssizeof parameters"%i %i"idquantidade);
        
printf("PARA: %i"parameters);
        
cmd_pay(playeridparameters);
    } 
PHP Code:
CMD:pay(playeridparams[]) {
    
printf("pay 1");
    if(
Logado[playerid] == 0) return 0;
    new 
idquantidadestring[128];
    
printf("pay 2");
    if(
sscanf(params,"ui"idquantidade)) return SendClientMessage(playerid, -1"Use: /pay [id] [ammount]");
    
printf("pay 3");
    if(
GetPlayerMoneyEx(playerid) < quantidade) return SendClientMessage(playerid, -1"You don't have this money!");
    if(
playerid == id) return SendClientMessage(playerid, -1"You can't use this command for yourself");
    if(
GetPlayerLevel(playerid"lvl") < 2) return SendClientMessage(playerid, -1"You need to be level 2 or higher");
    
printf("pay 4");
    if(
id != INVALID_PLAYER_ID) {
        if(
morto[playerid] > 0) return SendClientMessage(playeridCOLOR_RED"You can not use this command killed.");
        new 
Float:Pos[3];
        
GetPlayerPos(idPos[0], Pos[1], Pos[2]);
        if(
IsPlayerInRangeOfPoint(playerid5.0Pos[0], Pos[1], Pos[2])) {
            
format(stringsizeof(string), " %s paid %i$ to %s."PlayerName(playerid), quantidadePlayerName(id));
            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            
GivePlayerMoneyEx(idquantidade);
            
GivePlayerMoneyEx(playerid, -quantidade);
            
PlayerPlaySound(playerid10520.00.00.0);
            
PlayerPlaySound(id10520.00.00.0);
        }
    }
    
printf("pay 5");
    return 
1;

binnyl is offline   Reply With Quote
Old 22/05/2019, 05:14 PM   #10
TheToretto
Gangsta
 
TheToretto's Avatar
 
Join Date: Jul 2015
Posts: 597
Reputation: 66
Default Re: How to force a command in zcmd

Make it a function ready to be used more than once.

pawn Code:
PayPlayer(playerid, receiverid, amount){
    if(morto[playerid] > 0) return SendClientMessage(playerid, COLOR_RED, "You can not use this command killed.");
    new Float:Pos[3];
    GetPlayerPos(receiverid, Pos[0], Pos[1], Pos[2]);
    if(IsPlayerInRangeOfPoint(playerid, 5.0, Pos[0], Pos[1], Pos[2])) {
        new string[144];
        format(string, sizeof(string), " %s paid %i$ to %s.", PlayerName(playerid), amount, PlayerName(receiverid));
        printf("%s", string);
        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        GivePlayerMoneyEx(receiverid, amount);
        GivePlayerMoneyEx(playerid, -amount);
        PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
        PlayerPlaySound(receiverid, 1052, 0.0, 0.0, 0.0);
    }
}

Example:

pawn Code:
CMD:pay(playerid, params[]) {
    printf("pay 1");
    if(Logado[playerid] == 0) return 0;
    new id, quantidade, string[128];
    printf("pay 2");
    if(sscanf(params,"ui", id, quantidade)) return SendClientMessage(playerid, -1, "Use: /pay [id] [ammount]");
    printf("pay 3");
    if(GetPlayerMoneyEx(playerid) < quantidade) return SendClientMessage(playerid, -1, "You don't have this money!");
    if(playerid == id) return SendClientMessage(playerid, -1, "You can't use this command for yourself");
    if(GetPlayerLevel(playerid, "lvl") < 2) return SendClientMessage(playerid, -1, "You need to be level 2 or higher");
   

    PayPlayer(playerid, id, quantidade); // <--
    printf("pay 5");
    return 1;
}
__________________






Toretto#9902

Rest in peace grandpa, 03 November 2018
TheToretto is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
/sudo , force player to use command TokicMajstor Scripting Help 1 01/04/2019 12:54 PM
how to force a command Akeem Scripting Help 20 09/02/2018 04:19 AM
Force a player to run a command BigBrainAFK Scripting Help 16 19/07/2015 10:50 PM
How to force player to write a command? Micius Scripting Help 1 17/07/2013 08:31 PM
How to create Force command /reclass? [REP+] [FoR]EveR Scripting Help 4 02/04/2012 01:59 PM


All times are GMT. The time now is 01:33 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.