Difference between revisions of "$puttok"

From Scriptwiki
Jump to: navigation, search
(Replaced example to stop users using findtok and puttok to replace and added also see reptok section.)
 
Line 12: Line 12:
 
  echo -ag %botinfo
 
  echo -ag %botinfo
 
This example depending upon if ''%admin'' is [[$true]] or [[$false]] sets the third word in ''%botinfo'' to ''Yes'' or ''No''.
 
This example depending upon if ''%admin'' is [[$true]] or [[$false]] sets the third word in ''%botinfo'' to ''Yes'' or ''No''.
  '''Varibles set:'''
+
  '''Variables set:'''
 
  ''%gather_info = L,Q,G,O,F,S,P,Dana myserver.com 12345 10''  ;;Players Server Port MaxPlayers
 
  ''%gather_info = L,Q,G,O,F,S,P,Dana myserver.com 12345 10''  ;;Players Server Port MaxPlayers
 
   
 
   
Line 22: Line 22:
 
   }
 
   }
 
  }
 
  }
== Also see ==
+
 
[[$reptok]]
 
 
[[Category:Token Identifiers]]
 
[[Category:Token Identifiers]]

Latest revision as of 21: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.
  }
}