gettok | Multi Theft Auto: Wiki Skip to content

gettok

Client-side
Server-side
Shared

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function splits a string using the given separating character and returns one specified substring.

Syntax

gettok ( )

Code Examples

server

This example retrieves the startskin and endskin for spawning a player from a string of two numbers "a,b"

-- Put the string with the skins in a variable. Normally you would read it from a .map file or something.
local skins = "20,30"
-- Get the startskin and endskin strings ("20" and "30" in this case)
local startskin = gettok ( skins, 1, ',')
local endskin = gettok ( skins, 2, ',' )
-- Get a random skin in the range
local skin = math.random ( tonumber(startskin), tonumber(endskin) )