AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] (https://forums.alliedmods.net/showthread.php?t=295287)

DarthMan 03-21-2017 10:48

[HELP]
 
Hello.

Code:

new const g_weaps[] =
{
    "weapon_357",
    "weapon_9mmAR",
    "weapon_9mmhandgun",
    "weapon_crossbow",
    "weapon_crowbar",
    "weapon_egon",
    "weapon_gauss",
    "weapon_handgrenade",
    "weapon_hornetgun",
    "weapon_rpg",
    "weapon_satchel",
    "weapon_shotgun",
    "weapon_snark",
    "weapon_tripmine"
}

How can i check if arg2 contains an item from this list, and if it does, to give_item(player,arg2) ?
Thanks !

D3XT3R 03-21-2017 11:03

Re: [HELP]
 
explain to us more....

DarthMan 03-21-2017 11:05

Re: [HELP]
 
Quote:

Originally Posted by D3XT3R (Post 2505383)
explain to us more....

Well, I amde a command max_give_weapon Usage : player, weapon
I want to check if arg2 contains an item from the g_weaps enumeration to give the player the item from arg2 and display the emssages.Else, it should jsut display a message that the weapon is not valid.

Code:

give_item(player,arg2)
console_print(id, "Admin %s gave %s ^"%s^".", g_szPlayerName,player,arg2)
client_print(0,print_chat,"* Admin %s gave %s ^"%s^".", g_szPlayerName,player,arg2)


edon1337 03-21-2017 11:28

Re: [HELP]
 
Code:
for ( new i; i < sizeof g_weaps; i++ ) if( contain( arg2, g_weaps[ i ] ) )

DarthMan 03-21-2017 11:30

Re: [HELP]
 
Quote:

Originally Posted by edon1337 (Post 2505391)
Code:
for ( new i; i < sizeof g_weaps; i++ ) if( contain( arg2, g_weaps[ i ] ) )

But that will loop the messages for every i :(
It gave me a client overflow :(
I have tried with a var, but the text is displayed no matter what I type on arg2.

PRoSToTeM@ 03-21-2017 12:17

Re: [HELP]
 
Use Trie for this.

DarthMan 03-21-2017 12:22

Re: [HELP]
 
Quote:

Originally Posted by PRoSToTeM@ (Post 2505399)
Use Trie for this.

Wut do u mean?

Natsheh 03-21-2017 16:19

Re: [HELP]
 
This array is wrong sized ( new const g_weaps[] ) should be like this >> ( new const g_weaps[][] )


And btw what edon post is right. Btw u dont get overflow unless u put in the msg in the loop

DarthMan 03-21-2017 16:37

Re: [HELP]
 
Quote:

Originally Posted by Natsheh (Post 2505467)
This array is wrong sized ( new const g_weaps[] ) should be like this >> ( new const g_weaps[][] )


And btw what edon post is right. Btw u dont get overflow unless u put in the msg in the loop

The plug-in is almost done, there's only 1 small error that have to be fixed.

OciXCrom 03-21-2017 19:51

Re: [HELP]
 
I assume we need to guess what that is. I'll go first - a turtle is born upside down every time you use the plugin.


All times are GMT -4. The time now is 17:58.

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