Raised This Month: $ Target: $400
 0% 

problem with a plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tede7
New Member
Join Date: Jan 2009
Old 01-14-2009 , 04:17   problem with a plugin
Reply With Quote #1

hi.
Can anyone check this plugin and say whats wrong with it??
When i compile it, i get two errors:
Code:
/home/groups/amxmodx/tmp3/textFLiayE.sma(38) : error 035: argument type mismatch (argument 2)
/home/groups/amxmodx/tmp3/textFLiayE.sma(44) : warning 203: symbol is never used: "clantag"
I dont know why that argument make an error (coz it's a string ;/).
Also helpful would be to make an array instead of string clantag.

I know those could be stupid questions but im new with amxx scripting. I couldn't find any plugin that would do something like this, so I tried to make it ;D. I used to be only a webdeveloper ;P

Here's what I made: (it should add a "[Freelancer]" tag in front of nick if u dont have "[RoD]" tag in it.)
Code:
#include <amxmodx>

new NAME[] = "AddClanTag" 
new AUTHOR[] = "Tede" 
new VERSION[] = "0.5" 

new String:clantag = "[RoD]"

public plugin_init()
{
  register_plugin(NAME,VERSION,AUTHOR)
  register_cvar("amx_addclantag","1")
} 

public client_connect(id)
{
  new name[32]
  get_user_name(id, name, 32)
  check_name(id,name)
  return PLUGIN_CONTINUE
}

public client_infochanged(id)
{ 
   if (is_user_connected(id)){ 
      new newname[32]
      get_user_info(id,"name",newname,32) 
      check_name(id,newname) 
   } 
   return PLUGIN_CONTINUE 
} 
public check_name(id,username[])
{ 
  if (!get_cvar_num("amx_addclantag"))
  {
    return PLUGIN_CONTINUE
  }
  if (contain(username,clantag) == -1){ 
    new nname[32]
    format(nname,32,"[Freelancer]%s",username)
    set_user_info(id,"name",nname) 
  } 
  return PLUGIN_CONTINUE 
}
I tried to make an array so i changed line defining string for something like that:
Code:
new Array:clantags = {"[RoD]", "[SV]", "Cookies|"}
and function check_name for:
Code:
public check_name(id,username[])
{ 
  if (!get_cvar_num("amx_addclantag"))
  {
    return PLUGIN_CONTINUE
  }
  new z = sizeof(clantags)
  for ( new i; i < z - 1; i++ )
    {
        if (contain(username,clantags) == -1) PLUGIN_CONTINUE
    }
  new nname[32]
  format(nname,32,"[Freelancer]%s",username)
  set_user_info(id,"name",nname) 
  return PLUGIN_CONTINUE 
}
but it still dont work ;(
i gives an error with argument type mismatch in if (contain(... but when I type clantags[i] it makes such errors:
Code:
/home/groups/amxmodx/tmp3/textFcaKJe.sma(41) : error 028: invalid subscript (not an array or too many subscripts): "clantags"
/home/groups/amxmodx/tmp3/textFcaKJe.sma(41) : warning 215: expression has no effect
/home/groups/amxmodx/tmp3/textFcaKJe.sma(41) : error 001: expected token: ";", but found "]"
/home/groups/amxmodx/tmp3/textFcaKJe.sma(41) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/textFcaKJe.sma(41) : fatal error 107: too many error messages on one line

Last edited by tede7; 01-14-2009 at 07:54. Reason: mistake with pasting code ;D
tede7 is offline
Dr.G
Senior Member
Join Date: Nov 2008
Old 01-14-2009 , 05:36   Re: problem with a plugin
Reply With Quote #2

#1
PHP Code:
public client_infochanged(id)

   if (
is_user_connected(id)){ 
      new 
newname[32]
      
get_user_info(id,"name",newname,32
      
check_name(id,newname
   } 
   return 
PLUGIN_CONTINUE 
#include <amxmodx> 
What is that #include doing here?

#2
http://forums.alliedmods.net/showthread.php?t=6481
__________________
Dr.G is offline
tede7
New Member
Join Date: Jan 2009
Old 01-14-2009 , 07:56   Re: problem with a plugin
Reply With Quote #3

Quote:
Originally Posted by Dr.G View Post
What is that #include doing here?
sry ;D by mistake I pasted my code twice.
tede7 is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 01-14-2009 , 07:31   Re: problem with a plugin
Reply With Quote #4

clantags is a cellarray, not a simple array. Cellarray's are done differently. That is why you are getting an error.
__________________
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
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 01-14-2009 , 09:22   Re: problem with a plugin
Reply With Quote #5

There is no String: data type. It is a simple array. This should help you understand how to do it, http://wiki.alliedmods.net/Pawn_Tutorial
__________________
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
tede7
New Member
Join Date: Jan 2009
Old 01-14-2009 , 13:19   Re: problem with a plugin
Reply With Quote #6

it works ;D thanks guys
only last question: is it posible to make a regular expression?? I've read about regex_amxx module, but it gives only 3 functions and in need something like:
Code:
//PERL code:
if (username =~ s/(\[|\{|<)[A-Za-z0-9!@#$%^&*()](\]|\}|>)/){...
I tried this code, coz i thought it would work with regex module but it wasn't even compiled. ;/
(compilation errors: )
Code:
/home/groups/amxmodx/tmp3/textce83a5.sma(38) : warning 211: possibly unintended assignment
/home/groups/amxmodx/tmp3/textce83a5.sma(38) : error 046: unknown array size (variable "username")
/home/groups/amxmodx/tmp3/textce83a5.sma(38) : error 017: undefined symbol "s"
/home/groups/amxmodx/tmp3/textce83a5.sma(38) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/textce83a5.sma(38) : fatal error 107: too many error messages on one line
It would make this plugin more dynamic. ;D
tede7 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-14-2009 , 14:50   Re: problem with a plugin
Reply With Quote #7

http://www.amxmodx.org/funcwiki.php?go=func&id=622
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
tede7
New Member
Join Date: Jan 2009
Old 01-15-2009 , 14:05   Re: problem with a plugin
Reply With Quote #8

Thanks for url ;)

Does anyone knows why code below gives an error? It's something with this regular expression, but i dont know what exactly...
Code:
new Regex:was_tag_found = regex_match(username, "^(\{|\[|\}|\]|\(|\)|\+|-|=|:|\.|\^|\*)*[A-Za-z0-9!@#$%&;:.]{2,}(\{|\[|\}|\]|\(|\)|\+|-|=|:|\.|\^|\*)*.*$", regex_num, regex_error, 127);
tede7 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 01:39.


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