AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Error: Number of arguments does not match definition (https://forums.alliedmods.net/showthread.php?t=237461)

Flick3rR 03-24-2014 14:59

[HELP] Error: Number of arguments does not match definition
 
Hi, guys! I have some error and I don't know how exactly to fix it. I've searched, but I didn't find solution. The error appears on the line with:
PHP Code:

if(cs_get_user_model(id) == "sas.mdl"

and
PHP Code:

if(cs_get_user_model(id) == "leet.mdl"

This is the code. The main idea is a part of a menu, which sets the user a model of a player from he other team. Or "chameleon" option. Thanks in advance!

PHP Code:

                {
                    if(
cs_get_user_model(id) == "leet.mdl")
                        {
                            
ColorMessage(id"^3Tova veche go ^4imash^3!");    
                            return 
PLUGIN_HANDLED;
                        }
                    else
                        {
                            
cs_set_user_model(id,"leet.mdl");
                        }
                }
            else
                {
                    if(
cs_get_user_model(id) == "sas.mdl")
                        {
                            
ColorMessage(id"^3Tova veche go ^4imash^3!");    
                            return 
PLUGIN_HANDLED;
                        }
                    else
                        {
                            
cs_set_user_model(id,"sas.mdl");
                        }
                } 


fysiks 03-24-2014 15:08

Re: [HELP] Error: Number of arguments does not match definition
 
When you get this error, your first action should be to look up the function in the include files to see what arguments you need:

Code:

/* Get user model.
 */
native cs_get_user_model(index, model[], len);

In this case, it needs three arguments. The model string will be populated with the model and 'len' is the maximum length of the string variable that you use for 'model'.

The other thing is that in Pawn, you can't (or shouldn't; I can't remember which) compare strings by using equal signs. Use the equal() or equali() function.

YamiKaitou 03-24-2014 15:27

Re: [HELP] Error: Number of arguments does not match definition
 
You also set and retrieve model names without the extension

Flick3rR 03-24-2014 15:41

Re: [HELP] Error: Number of arguments does not match definition
 
Thanks, guys! I actually fixed the problem by replacing
PHP Code:

if(cs_get_user_model(id) == "leet.mdl"

with
PHP Code:

if(cs_get_user_model(id"sas"4)) 

And actually the main problem was, that I always forget the extension of the model and it's not setting... :D I'm little dumb, but..
Allright, the problem is fixed!

---EDIT----
Allright... I've fixed the errors, but the whole func is not working.... Strange. It's about a menu item (Chameleon), what has to set the user model of player from the other team (in this case - leet and sas). So, i'll post the whole case and if you know why it's not working, it'll be great if you share the problem :)

PHP Code:

        case 5:
        {
            new 
iMoney cs_get_user_money(id);
            new 
iPrice 6850;
            if (!(
is_user_alive(id)))
                {
                    
ColorMessage(id"^4%s ^3You've to be ^4alive^3, to buy this item!");
                    return 
PLUGIN_HANDLED;
                }
            if (!(
cs_get_user_money(id) >= iPrice))
                {
                    
ColorMessage(id"^4%s ^3You don't have enough ^4money!");
                    return 
PLUGIN_HANDLED;
                }
            if(
cs_get_user_team(id) == CS_TEAM_CT)
                {
                    if(
cs_get_user_model(id"leet"4))
                        {
                            
ColorMessage(id"^3You already have ^4Chameleon^3!");    
                            return 
PLUGIN_HANDLED;
                        }
                    else
                        {
                            
cs_set_user_model(id,"leet");
                        }
                }
            else
                {
                    if(
cs_get_user_model(id"sas"4))
                        {
                            
ColorMessage(id"^3You already have ^4Chameleon^3!");    
                            return 
PLUGIN_HANDLED;
                        }
                    else
                        {
                            
cs_set_user_model(id,"sas");
                        }
                }
            
cs_set_user_money(idiMoney iPrice);
            
ColorMessage(id"^3%s ^4Ti kupi ^3Chameleon"PREFIX);
        } 


YamiKaitou 03-24-2014 15:43

Re: [HELP] Error: Number of arguments does not match definition
 
Your fix does nothing and is incorrect

Flick3rR 03-24-2014 15:56

Re: [HELP] Error: Number of arguments does not match definition
 
Quote:

Originally Posted by YamiKaitou (Post 2115459)
Your fix does nothing and is incorrect

Well, I'm still noob, so if you can help somehow... :cry::oops:

fysiks 03-24-2014 16:03

Re: [HELP] Error: Number of arguments does not match definition
 
To use strings:

PHP Code:

new szString[32];
cs_get_user_model(idszStringcharsmax(szString));
// szString now contains the model name. 

Then, you need to compare szString using equal() or equali() depending on if you want case sensitivity. You can search for uses of equal() and/or equali() if you don't know how to use them.

Flick3rR 03-24-2014 16:33

Re: [HELP] Error: Number of arguments does not match definition
 
Look, I don't really understand what I'm i supposed to do, mostly beacause I cant simply translate your termins to my language :D Mainly I understand, but I can't get the details. So, I want to tell you, that in this case (with giving AWP):
PHP Code:

        case 4:
        {
            new 
iMoney cs_get_user_money(id);
            new 
iPrice 13000;
            if (!(
is_user_alive(id)))
                {
                    
ColorMessage(id"^4%s ^3You've to be ^4alive^3, to buy this item!"PREFIX);
                    return 
PLUGIN_HANDLED;
                }
            if (!(
cs_get_user_money(id) >= iPrice))
                {
                    
ColorMessage(id"^4%s ^3You don't have enough ^4money!"PREFIX);
                    return 
PLUGIN_HANDLED;
                }
            if (
get_user_weapon(id) == CSW_AWP)
                {
                    
ColorMessage(id"^4%s ^3You already have this ^4item^3!"PREFIX);
                    return 
PLUGIN_HANDLED;
                }
            
give_item(id"weapon_awp");
            
cs_set_user_bpammo(idCSW_AWP30);
            
cs_set_user_money(idiMoney iPrice);
            
ColorMessage(id"^3%s ^4You bought ^3AWP"PREFIX); 

All the things are working, but in the case with the model, NOTHING of these doesn't work. I mean, even the messages if you don't have the money or if you are dead. So, I think, that some return PLUGIN_HANDLED could mess something, or idk... It doesn't even take the money, display the message or something - nothing happens. In case, that most of the thing are the same, idk why even the main functions aren't working and I think, that the problem could not be with the model precache (or set), but somewhere else. I'm sorry that I'm messing your work with my problems, but it'll be super if you could help me, when you have time! My excuses again, and thanks! :oops:

fysiks 03-24-2014 17:04

Re: [HELP] Error: Number of arguments does not match definition
 
Please post the whole .sma file as an attachment (don't copy and paste the code into the post) so that it will be much easier to help you.

minato 03-25-2014 00:15

Re: [HELP] Error: Number of arguments does not match definition
 
PHP Code:

case 5

    new 
iMoney cs_get_user_money(id); 
    new 
CsTeams:team cs_get_user_team(id);
    new 
iPrice 6850
    new 
model[32];
    
cs_get_user_model(idmodelcharsmax(model))
    
    if (!(
is_user_alive(id))) 
    { 
        
ColorMessage(id"^4%s ^3You've to be ^4alive^3, to buy this item!"); 
        return 
PLUGIN_HANDLED
    } 
    
    if (!(
iMoney >= iPrice)) 
    { 
        
ColorMessage(id"^4%s ^3You don't have enough ^4money!"); 
        return 
PLUGIN_HANDLED
    } 
    
    switch(
team){
            
        case 
CS_TEAM_CT:
        {
            if(
equal(model"leet")) 
            { 
                
ColorMessage(id"^3You already have ^4Chameleon^3!");     
                return 
PLUGIN_HANDLED
            } 
            else
                
cs_set_user_model(id,"leet"); 
                
        }
        case 
CS_TEAM_T:
        {
            if(
equal(model"sas")) 
            { 
                
ColorMessage(id"^3You already have ^4Chameleon^3!");     
                return 
PLUGIN_HANDLED
            } 
            else 
                
cs_set_user_model(id,"sas"); 
            
        }
    
    }
    
    
cs_set_user_money(idiMoney iPrice); 
    
ColorMessage(id"^3%s ^4Ti kupi ^3Chameleon"PREFIX); 




All times are GMT -4. The time now is 06:00.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.