SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 19/05/2019, 02:21 PM   #1
binnyl
Big Clucker
 
Join Date: Aug 2017
Posts: 168
Reputation: 2
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 online now   Reply With Quote
Old 19/05/2019, 02:54 PM   #2
Mobtiesgangsa
Big Clucker
 
Join Date: Oct 2016
Location: Somewhere in San Fierro near Binco.
Posts: 101
Reputation: 16
Default Re: How to force a command in zcmd

Turn this

PHP Code:
cmd_pay(playerididquantidade); 
into

PHP Code:
cmd_pay(playeridquantidade); 
__________________

this thread seems to amaze me
Quote:
Bolex_
Good question, simply when a reaction test appear you'r are going to type randm numbers and earn some cash & money!
Me: Earn some cash and Money hahahahahahah, or maybe Dolars and Euros XD
Mobtiesgangsa is online now   Reply With Quote
Old 19/05/2019, 04:48 PM   #3
binnyl
Big Clucker
 
Join Date: Aug 2017
Posts: 168
Reputation: 2
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 online now   Reply With Quote
Old 19/05/2019, 05:27 PM   #4
Koreadars
Big Clucker
 
Join Date: Mar 2019
Location: Czech Republic, Prdelákov.
Posts: 121
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, 03:24 AM   #5
binnyl
Big Clucker
 
Join Date: Aug 2017
Posts: 168
Reputation: 2
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 10:19 AM.
binnyl is online now   Reply With Quote
Old 21/05/2019, 10:19 AM   #6
binnyl
Big Clucker
 
Join Date: Aug 2017
Posts: 168
Reputation: 2
Default Re: How to force a command in zcmd

EDIT, it's not working!
binnyl is online now   Reply With Quote
Old 21/05/2019, 10:38 AM   #7
Koreadars
Big Clucker
 
Join Date: Mar 2019
Location: Czech Republic, Prdelákov.
Posts: 121
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, 10:55 AM   #8
cSharp
Big Clucker
 
Join Date: Oct 2018
Posts: 64
Reputation: 13
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, 03:31 PM   #9
binnyl
Big Clucker
 
Join Date: Aug 2017
Posts: 168
Reputation: 2
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 online now   Reply With Quote
Old 22/05/2019, 04:14 PM   #10
TheToretto
Gangsta
 
TheToretto's Avatar
 
Join Date: Jul 2015
Posts: 593
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 11:54 AM
how to force a command Akeem Scripting Help 20 09/02/2018 03:19 AM
Force a player to run a command BigBrainAFK Scripting Help 16 19/07/2015 09:50 PM
How to force player to write a command? Micius Scripting Help 1 17/07/2013 07:31 PM
How to create Force command /reclass? [REP+] [FoR]EveR Scripting Help 4 02/04/2012 12:59 PM


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


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