Raised This Month: $ Target: $400
 0% 

Dumb Question..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Gari
New Member
Join Date: Jun 2007
Old 06-27-2007 , 23:52   Dumb Question..
Reply With Quote #1

Hey, I'm just starting to poke around with AMXX code.. only really good with C++.. which makes me feel like an idiot right now (not being able to find where the error is..)

But with the ts_giveweapon function in tsfun.inc.. I keep getting a type mismatch.

Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <tsfun>

public plugin_init() {
    register_plugin("Test", "Alpha 1", "Gari")
    register_concmd("amx_get", "cmd_getwep", ADMIN_SLAY, " <target> <weapon> <clips> <addons> ")
}

public cmd_getwep(id, level, cid)
{
    if(!cmd_access(id, level, cid, 3))
    {
        console_print(id, "Sorry, you do not have access to amx_give.")
        return PLUGIN_HANDLED
    }
    
    new index[25]
    new weapon[3]
    new clips[4]
    new extra[3]
    
    read_argv(1, index, 24)
    read_argv(2, weapon, 2)
    read_argv(3, clips, 3)
    read_argv(4, extra, 2)
    
    ts_giveweapon( index,weapon,clips,extra )
    
    return PLUGIN_HANDLED
}
Can someone tell me if its the ts_giveweapon function that is restricting this from compiling or is it one of my read arguments?
Gari is offline
kmal2t
BANNED
Join Date: Apr 2006
Old 06-28-2007 , 00:25   Re: Dumb Question..
Reply With Quote #2

Well for one I think you need to include tsx if I'm not mistaken. Two have a multi-array with these:

enum {
TSW_GLOCK18 = 1,
TSW_UNK1,
TSW_UZI,
TSW_M3,
TSW_M4A1,
TSW_MP5SD,
TSW_MP5K,
TSW_ABERETTAS,
TSW_MK23,
TSW_AMK23,
TSW_USAS,
TSW_DEAGLE,
TSW_AK47,
TSW_57,
TSW_AUG,
TSW_AUZI,
TSW_TMP,
TSW_M82A1,
TSW_MP7,
TSW_SPAS,
TSW_GCOLTS,
TSW_GLOCK20,
TSW_UMP,
TSW_M61GRENADE,
TSW_CKNIFE,
TSW_MOSSBERG,
TSW_M16A4,
TSW_MK1,
TSW_C4,
TSW_A57,
TSW_RBULL,
TSW_M60E3,
TSW_SAWED_OFF,
TSW_KATANA,
TSW_SKNIFE,
TSW_KUNG_FU,
TSW_TKNIFE,
}

and then have something like:
new clips, extra, weapon = blah blah
ts_giveweapon(id,weapon,clips,extra )

Last edited by kmal2t; 06-28-2007 at 00:28.
kmal2t is offline
Gari
New Member
Join Date: Jun 2007
Old 06-28-2007 , 09:42   Re: Dumb Question..
Reply With Quote #3

I included TSX and I set the variables to be something but it still gives me an argument mismatch on the first variable.
Gari is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 06-28-2007 , 10:15   Re: Dumb Question..
Reply With Quote #4

It looks like you're passing in index (a string - username?) when you want id (an integer - player slot on server?)

You need a cmd_target() or find_player() first, then pass the output of that into the give_weapon function
purple_pixie is offline
Gari
New Member
Join Date: Jun 2007
Old 06-28-2007 , 10:53   Re: Dumb Question..
Reply With Quote #5

Yeah that makes sense. Looking at some other code I realized that it was player id, not name. I'll try that out and let you know how it went.
Gari is offline
Gari
New Member
Join Date: Jun 2007
Old 06-28-2007 , 10:59   Re: Dumb Question..
Reply With Quote #6

I did the cmd_target(id, index, 15) and then it gave me a type mismatch on the second. I tried str_to_num(weapon) but it still gives me a mismatch...

Edit: I just made variables like weapon_num for the str_to_num function.. it compiles but no .amxx file is made.

Edit2: Nevermind, got it. Thanks everyone - I'm gonna go test this!

Last edited by Gari; 06-28-2007 at 11:02.
Gari is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 06-28-2007 , 11:06   Re: Dumb Question..
Reply With Quote #7

I don't really get cmd_target() to be perfectly honest, so I'd use find_player instead.

It also looks like all of the arguments should be integers.
I don't know if you can pass in a value as str_to_num, so I'll just make 4 new variables - what the hell.
Code:
new index[25]     new weapon[3]     new clips[4]     new extra[3]     read_argv(1,index,24)     read_argv(2, weapon, 2)     read_argv(3, clips, 3)     read_argv(4, extra, 2)     new target=find_player(index,"bl") // bl = partial name, only alive. (I think ;-)  )     if (!target)     {         client_print(id,print_chat,"Could not find player %s",index)         return PLUGIN_HANDLED     }     new weapon_id=str_to_num(weapon)     new clips_num=str_to_num(clips)     new extra_num=str_to_num(extra)     ts_giveweapon( id,weapon_id,clips_num,extra_num)

Last edited by purple_pixie; 06-28-2007 at 11:07. Reason: Adding "small" tags
purple_pixie is offline
Reply



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 21:33.


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