Difference between revisions of "$puttok"
From Scriptwiki
(One intermediate revision by one other user not shown) | |||
Line 7: | Line 7: | ||
[[echo]] -ag $puttok(This is a moo, test, 4, 32) | [[echo]] -ag $puttok(This is a moo, test, 4, 32) | ||
This example replaces ''moo'' with ''test'' and therefor echo's ''This is a test''. | This example replaces ''moo'' with ''test'' and therefor echo's ''This is a test''. | ||
− | [[var]] % | + | [[var]] %botinfo = Nick JoinTime Admin |
− | + | [[If-Then-Else|if]] (!%admin) { [[set]] %botinfo $puttok(%users.1,[[$nick]],3,No) } | |
− | + | else { [[set]] %botinfo $puttok(%users.1,[[$nick]],3,Yes) } | |
− | % | + | echo -ag %botinfo |
− | echo -ag % | + | This example depending upon if ''%admin'' is [[$true]] or [[$false]] sets the third word in ''%botinfo'' to ''Yes'' or ''No''. |
− | This example | + | '''Variables set:''' |
+ | ''%gather_info = L,Q,G,O,F,S,P,Dana myserver.com 12345 10'' ;;Players Server Port MaxPlayers | ||
+ | |||
+ | on *:[[On_Part|PART]]:#GatherChan: { | ||
+ | var %tmp.nicks = [[$gettok]](%gather_info,1,32) ;;Get nicknames into a temporary variable. | ||
+ | if ([[$istok]](%tmp.nicks,$nick,44)) { ;;If nickname is in gather ... | ||
+ | set %tmp.nicks [[$remtok]](%tmp.nicks,$nick,44) ;; remove them. | ||
+ | set %gather_info $puttok(%gether_info,%tmp.nicks,1,32) ;;Update ''%gather_info'''s first token with the players that are left. | ||
+ | } | ||
+ | } | ||
[[Category:Token Identifiers]] | [[Category:Token Identifiers]] |
Latest revision as of 20:08, 17 October 2005
Overwrites the Nth token in text with a new token.
$puttok(text,token,N,C)
Note that you can specify a negative N.
Example
echo -ag $puttok(This is a moo, test, 4, 32)
This example replaces moo with test and therefor echo's This is a test.
var %botinfo = Nick JoinTime Admin if (!%admin) { set %botinfo $puttok(%users.1,$nick,3,No) } else { set %botinfo $puttok(%users.1,$nick,3,Yes) } echo -ag %botinfo
This example depending upon if %admin is $true or $false sets the third word in %botinfo to Yes or No.
Variables set: %gather_info = L,Q,G,O,F,S,P,Dana myserver.com 12345 10 ;;Players Server Port MaxPlayers on *:PART:#GatherChan: { var %tmp.nicks = $gettok(%gather_info,1,32) ;;Get nicknames into a temporary variable. if ($istok(%tmp.nicks,$nick,44)) { ;;If nickname is in gather ... set %tmp.nicks $remtok(%tmp.nicks,$nick,44) ;; remove them. set %gather_info $puttok(%gether_info,%tmp.nicks,1,32) ;;Update %gather_info's first token with the players that are left. } }