Raised This Month: $ Target: $400
 0% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 03-24-2014 , 14:59   [HELP] Error: Number of arguments does not match definition
Reply With Quote #1

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");
                        }
                } 
Flick3rR is offline
Send a message via Skype™ to Flick3rR
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-24-2014 , 15:08   Re: [HELP] Error: Number of arguments does not match definition
Reply With Quote #2

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.
__________________
fysiks is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 03-24-2014 , 15:27   Re: [HELP] Error: Number of arguments does not match definition
Reply With Quote #3

You also set and retrieve model names without the extension
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 03-24-2014 , 15:41   Re: [HELP] Error: Number of arguments does not match definition
Reply With Quote #4

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... 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);
        } 

Last edited by Flick3rR; 03-24-2014 at 15:53.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 03-24-2014 , 15:43   Re: [HELP] Error: Number of arguments does not match definition
Reply With Quote #5

Your fix does nothing and is incorrect
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 03-24-2014 , 15:56   Re: [HELP] Error: Number of arguments does not match definition
Reply With Quote #6

Quote:
Originally Posted by YamiKaitou View Post
Your fix does nothing and is incorrect
Well, I'm still noob, so if you can help somehow...
Flick3rR is offline
Send a message via Skype™ to Flick3rR
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-24-2014 , 16:03   Re: [HELP] Error: Number of arguments does not match definition
Reply With Quote #7

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.
__________________
fysiks is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 03-24-2014 , 16:33   Re: [HELP] Error: Number of arguments does not match definition
Reply With Quote #8

Look, I don't really understand what I'm i supposed to do, mostly beacause I cant simply translate your termins to my language 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!

Last edited by Flick3rR; 03-24-2014 at 16:34.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-24-2014 , 17:04   Re: [HELP] Error: Number of arguments does not match definition
Reply With Quote #9

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.
__________________
fysiks is offline
minato
Senior Member
Join Date: May 2010
Location: Rosario
Old 03-25-2014 , 00:15   Re: [HELP] Error: Number of arguments does not match definition
Reply With Quote #10

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); 

__________________

Last edited by minato; 03-25-2014 at 00:18.
minato is offline
Send a message via MSN to minato
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

Forum Jump


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


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