AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   have some problem with func. "contain" (https://forums.alliedmods.net/showthread.php?t=60478)

Ltv 09-04-2007 13:33

have some problem with func. "contain"
 
Hi.

I have problem with function contain/containi
When i tried to read from file, I have faced a problem. If in file

Quote:

de_aztec
de_dust
etc.
Then when i want do something with the de_dust2, the plug-in check dust2 as dust

command de_Dust2 as command de_Dust

Code:


if((containi(arg,read) != -1))
  {
    console_print(id, "%L", id, "NOT_ALLOW_LMP")
    return PLUGIN_HANDLED
  }

Sorry for my bad english.

Greenberet 09-04-2007 15:24

Re: have some problem with func. "contain"
 
use equali

Ltv 09-05-2007 04:56

Re: have some problem with func. "contain"
 
One more specification

Code:


for (new i=0; i < 4; i++) {
 if((containi(arg[i],read) != -1))
    {
    console_print(id, "%L", id, "NOT_ALLOW_LMP")
    return PLUGIN_HANDLED
    }
}

and when i use equali , the plugin do plugin handled to all maps,
even on those which are not entered in the file.

if i do so

Code:


 if(equali(arg[0],read))
    {
    console_print(id, "%L", id, "NOT_ALLOW_LMP")
    return PLUGIN_HANDLED
    }

then work, but only with one maps :(

i tried do

Code:


 if(equali(arg[0],read) || equali(arg[1],read) || equali(arg[2],read)...)
    {
    console_print(id, "%L", id, "NOT_ALLOW_LMP")
    return PLUGIN_HANDLED
    }

It works also as with a cycle

_Master_ 09-05-2007 07:23

Re: have some problem with func. "contain"
 
Perhaps you'd do better to explain the rationale of your plugin.
Small modifications to containi() and equali() may result in completely different results. Specially if they are used in parsing loops.

[ --<-@ ] Black Rose 09-05-2007 17:20

Re: have some problem with func. "contain"
 
Post your full code ( what the fuck is arg and read? ).

_Master_ 09-06-2007 03:17

Re: have some problem with func. "contain"
 
@ [ --<-@ ] Black Rose : That's exactly why I've requested the plugin rationale. Also, nice to have you back. :up:

Ltv 09-06-2007 11:04

Re: have some problem with func. "contain"
 
Here all part, the rest adminvote.sma, a part public cmdVoteMap

Code:


 new fz = file_size(lastmapsfile,1) + 1
 for(new i=0 ;i<=fz; i++)
 {
  new read[100]
  new trash
  read_file(lastmapsfile,i,read,99,trash)
  for(new i=0; i < 4; i++) {
  if((containi(g_optionName[i],read)!=-1))
  {
    console_print(id, "%L", id, "NOT_ALLOW_LMP")
    return PLUGIN_HANDLED
  }
  }
 }


_Master_ 09-06-2007 11:40

Re: have some problem with func. "contain"
 
Ltv, Please post the full code. I can only guess what g_optionName[] is and what string(s?) it may or may not hold.
Also it would be nice to know what are you trying to do. Like deny all votes for: maps starting with... OR maps containing... OR map group... OR ... what ?

Thx.

Ltv 09-06-2007 14:00

Re: have some problem with func. "contain"
 
1 Attachment(s)
I try to make that the admin could not put voting on maps from a file lastmapsplayed.txt

Code:


new configsdir[200]
new lastmapsfile[200]
 
get_configsdir(configsdir,199)
 format(lastmapsfile,199,"%s/lastmapsplayed.txt",configsdir)


Code:


public cmdVoteMap(id, level, cid)
{
 if (!cmd_access(id, level, cid, 2))
  return PLUGIN_HANDLED
 
 new Float:voting = get_cvar_float("amx_last_voting")
 if (voting > get_gametime())
 {
  console_print(id, "%L", id, "ALREADY_VOTING")
  return PLUGIN_HANDLED
 }
 
 if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime())
 {
  console_print(id, "%L", id, "VOTING_NOT_ALLOW")
  return PLUGIN_HANDLED
 }
 
 new argc = read_argc()
 if (argc > 5) argc = 5
 
 g_validMaps = 0
 g_optionName[0][0] = 0
 g_optionName[1][0] = 0
 g_optionName[2][0] = 0
 g_optionName[3][0] = 0
 
 
 for (new i = 1; i < argc; ++i)
 {
  read_argv(i, g_optionName[g_validMaps], 31)
 
  if (is_map_valid(g_optionName[g_validMaps]))
  g_validMaps++
 }
//[START]
 new fz = file_size(lastmapsfile,1) + 1
 for(new i=0 ;i<=fz; i++)
 {
  new read[100]
  new trash
  read_file(lastmapsfile,i,read,99,trash)
  for(new i=0; i < 4; i++) {
  if((containi(g_optionName[i],read)!=-1))
  {
    console_print(id, "%L", id, "NOT_ALLOW_LMP")
    return PLUGIN_HANDLED
  }
  }
 }
//[END]
 
 if (g_validMaps == 0)
 {
  new lMaps[16]
 
  format(lMaps, 15, "%L", id, (argc == 2) ? "MAP_IS" : "MAPS_ARE")
  console_print(id, "%L", id, "GIVEN_NOT_VALID", lMaps)
  return PLUGIN_HANDLED
 }
 new menu_msg[256], len = 0
 new keys = 0
 
 if (g_validMaps > 1)
 {
  keys = MENU_KEY_0
  len = format(menu_msg, 255, g_coloredMenus ? "\y%L: \w^n^n" : "%L: ^n^n", LANG_SERVER, "CHOOSE_MAP")
  new temp[128]
 
  for (new a = 0; a < g_validMaps; ++a)
  {
  format(temp, 127, "%d.  %s^n", a+1, g_optionName[a])
  len += copy(menu_msg[len], 255-len, temp)
  keys |= (1<<a)
  }
 
  format(menu_msg[len], 255-len, "^n0.  %L", LANG_SERVER, "NONE")
  g_yesNoVote = 0
 } else {
  new lChangeMap[32], lYes[16], lNo[16]
 
  format(lChangeMap, 31, "%L", LANG_SERVER, "CHANGE_MAP_TO")
  format(lYes, 15, "%L", LANG_SERVER, "YES")
  format(lNo, 15, "%L", LANG_SERVER, "NO")
  format(menu_msg, 255, g_coloredMenus ? "\y%s %s?\w^n^n1.  %s^n2.  %s" : "%s %s?^n^n1.  %s^n2.  %s", lChangeMap, g_optionName[0], lYes, lNo)
  keys = MENU_KEY_1|MENU_KEY_2
  g_yesNoVote = 1
 }
 
 new authid[32], name[32]
 
 get_user_authid(id, authid, 31)
 get_user_name(id, name, 31)
 
 if (argc == 2)
  log_amx("Vote: ^"%s<%d><%s><>^" vote map (map ^"%s^")", name, get_user_userid(id), authid, g_optionName[0])
 else
  log_amx("Vote: ^"%s<%d><%s><>^" vote maps (map#1 ^"%s^") (map#2 ^"%s^") (map#3 ^"%s^") (map#4 ^"%s^")", name, get_user_userid(id), authid, g_optionName[0], g_optionName[1], g_optionName[2], g_optionName[3])
 new lTag[16], activity = get_cvar_num("amx_show_activity")
 
 if (activity > 0)
 {
  new players[32], pnum
 
  get_players(players, pnum, "c")
  for (new i = 0; i < pnum; i++)
  {
  format(lTag, 15, "%L", players[i], is_user_admin(id) ? "ADMIN" : "PLAYER")
 
  switch (activity)
  {
    case 2: client_print(players[i], print_chat, "%L", players[i], "ADMIN_VOTE_MAP_2", lTag, name)
    case 1: client_print(players[i], print_chat, "%L", players[i], "ADMIN_VOTE_MAP_1", lTag)
  }
  }
 }
 g_execResult = true
 new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0
 
 set_cvar_float("amx_last_voting", get_gametime() + vote_time)
 g_voteRatio = get_cvar_float("amx_votemap_ratio")
 g_Answer = "changelevel %s"
 show_menu(0, keys, menu_msg, floatround(vote_time), (g_validMaps > 1) ? "Choose map: " : "Change map to ")
 set_task(vote_time, "checkVotes", 99889988)
 g_voteCaller = id
 console_print(id, "%L", id, "VOTING_STARTED")
 g_voteCount = {0, 0, 0, 0}
 
 return PLUGIN_HANDLED
}

has attached full file, just in case

Ltv 09-11-2007 15:55

Re: have some problem with func. "contain"
 
Help please anybody.


All times are GMT -4. The time now is 16:04.

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