AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   string help agen (https://forums.alliedmods.net/showthread.php?t=13495)

WaZZeR++ 05-18-2005 14:02

string help agen
 
I have a problem. I have a string:
Code:
g_Answer = arg2? "banid %d %s kick" : "banid 30.0 %s kick"
But i want the %d to be replaced by arg2. So the output become ie:
Code:
g_Answer = "banid 120.0 %s kick"

Jinto 05-18-2005 17:01

Code:

new szBanString[128];
format( szBanString, 127, "banid %d %s kick", arg1, arg2 );

use format to format the string how you want.

WaZZeR++ 05-19-2005 16:02

will this work?
Code:
format( g_Answer, 127, "banid %d %s kick", arg2 );

will the %s still be there?

v3x 05-20-2005 21:51

You've got a decimal (%d) and a string (%s) and only 1 arg, so.. nope.

Jinto 05-20-2005 23:08

Actually v3x your wrong.. %d is an integer

v3x 05-20-2005 23:47

My bad. :P

WaZZeR++ 05-21-2005 09:03

ok, have any idea how to make the output become:
"banid 120.0 %s kick"?

think this will work:
Code:
format( g_Answer, 127, "banid %d %s kick", arg2, "%s" );

v3x 05-21-2005 14:41

Post the whole function, please.

WaZZeR++ 05-21-2005 17:11

Im trying to modify the amx_voteban so you can ban by time...

Code:
/* Vote Ban amx_voteban <id> [time]*/ public cmdVoteBan(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 cmd[32]   read_argv(0,cmd,31)   new voteban = equal(cmd,"amx_voteban")   new arg[32]   read_argv(1,arg,31)   new player = cmd_target(id,arg,1)   if (!player) return PLUGIN_HANDLED   if (voteban && is_user_bot(player)) {     new imname[32]     get_user_name(player,imname,31)     console_print(id,"%L",id,"ACTION_PERFORMED",imname)     return PLUGIN_HANDLED   }   new arg2[32]   read_argv(2,arg2,31)   new keys = MENU_KEY_1|MENU_KEY_2   new menu_msg[256],lYes[16],lNo[16],lKickBan[16]   format(lYes,15,"%L",LANG_SERVER,"YES")   format(lNo,15,"%L",LANG_SERVER,"NO")   format(lKickBan,15,"%L",LANG_SERVER,"BAN")   ucfirst(lKickBan)   get_user_name(player,arg,31)   format(menu_msg,255,g_coloredMenus ?     "\y%s %s?\w^n^n1.  %s^n2.  %s" :     "%s %s?^n^n1.  %s^n2.  %s",     lKickBan, arg, lYes, lNo)   g_yesNoVote = 1   get_user_authid(player,g_optionName[0],31)   new authid[32],name[32]   get_user_authid(id,authid,31)   get_user_name(id,name,31)   log_amx("Vote: ^"%s<%d><%s><>^" vote %s (target ^"%s^")",     name,get_user_userid(id),authid,"ban",arg)   new activity = get_cvar_num("amx_show_activity")   if (activity>0) {     new players[32],pnum,lTag[16]     get_players(players,pnum,"c")     for (new i=0;i<pnum;i++) {       format(lTag,15,"%L",players[i],is_user_admin(id)?"ADMIN":"USER")       format(lKickBan,15,"%L",players[i],"BAN")       switch (activity) {         case 2: client_print(players[i],print_chat,"%L",           players[i],"ADMIN_VOTE_FOR_2",lTag,name,lKickBan,arg)         case 1: client_print(players[i],print_chat,"%L",           players[i],"ADMIN_VOTE_FOR_1",lTag,lKickBan,arg)       }     }   }   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_voteban_ratio")   g_Answer = arg2? format("banid %d %s kick",arg2) : "banid 30.0 %s kick"   show_menu(0,keys,menu_msg,floatround(vote_time),"Ban ")   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 }

Zky 06-14-2006 15:02

it's work ?


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

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