[+]: Invalid money [disable to add.]
#1

Hi, the server the player's money, 1000$ 2000$, 3000$ etc. integer how to get the block ..?
The amount of money 1000/2000/3000 server disable money amount.
Example;
PHP код:
GetMoneyFunction(playerid){
InvalidMoney(playerid);
SendClientMessage(playerid, -1, [Incorrect amount]: You do not get that amount.);

PHP код:
stock InvalidMoney(playerid){
GivePlayerMoney(playerid1000); // Disable
GivePlayerMoney(playerid2000); // Disable
GivePlayerMoney(playerid3000); // Disable

Reply
#2

PHP код:
CheckValidMoney(money) {
    new 
index 0//define index
    
switch(money) { //loop through input
        
case 1000index 1//check 1000
        
case 2000index 1;
        case 
3000index 1;
    }
    if(
index != 0) return false//return false if player money is not valid.
    
return true;
}

GivePlayerMoneyEx(playeridmoney) {
    if(!
CheckValidMoney(money)) return SendClientMessage(playerid, -1"[Incorrect amount]: You do not get that amount."); //If money amount is invalid, return error msg.
    
GivePlayerMoney(playeridmoney); //Give player money if above condition did not escape the function.
    
return 1;

Reply
#3

Quote:
Originally Posted by introzen
Посмотреть сообщение
PHP код:
CheckValidMoney(money) {
    new 
index 0//define index
    
switch(money) { //loop through input
        
case 1000index 1//check 1000
        
case 2000index 1;
        case 
3000index 1;
    }
    if(
index != 0) return false//return false if player money is not valid.
    
return true;
}
GivePlayerMoneyEx(playeridmoney) {
    if(!
CheckValidMoney(money)) return SendClientMessage(playerid, -1"[Incorrect amount]: You do not get that amount."); //If money amount is invalid, return error msg.
    
GivePlayerMoney(playeridmoney); //Give player money if above condition did not escape the function.
    
return 1;

You're not really looping. You're just checking value cases against the input. You can leave the index variable out:
PHP код:
switch(money) {
    case 
100020003000: {
        return 
false;
    }
    default: return 
true;

You would have to add all (n*1000) cases to match the OPs needs.
Something like this would probably be better:
PHP код:
return (input 1000 == 0) ? true false
Reply
#4

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
Something like this would probably be better:
PHP код:
return (input 1000 == 0) ? true false
You're completely right. Thank you.

I've just started using switch() instead of if() as i've read it should be more memory efficient.
Reply
#5

thanks but doesnt work :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)