Jump to content

find String rename


Fabioxps

Recommended Posts

Posted

if the name of the map and [old] to rename [OLDS]

function ismapDM(isim) 
    if string.find(isim, "[old]", 1, true) then 
        return string.find(isim, "[OLDS]", 1, true) 
  
    end 
end 

?

Posted

Are you mean renaming the resource name ? if so

renameResource 

If you are trying find [ old school map ] use this function

function ismapNameOLDS( mapName ) 
    return mapName:find( '[old]', 1, true ) or mapName:find( '[OLDS]', 1, true ) 
end 

  • MTA Team
Posted

You cannot rename directories as Multi Theft Auto views all resources in a flat structure and not within directory categories. Although re-reading your post it seems you're modifying the name of the map, and not the folder it resides inside.

Use

string.gsub(mapName, "[old]", "[OLDS]") 

Posted

that's right?

function initRace(vehicle, checkpoints, objects, pickups, mapoptions, ranked, duration, gameoptions, mapinfo, playerInfo) 
    outputDebug( 'MISC', 'initRace start' ) 
    unloadAll() 
     
    g_Players = getElementsByType('player') 
    g_MapOptions = mapoptions 
    g_GameOptions = gameoptions 
    g_MapInfo = mapinfo 
    g_PlayerInfo = playerInfo 
    triggerEvent('onClientMapStarting', g_Me, mapinfo ) 
removeEventHandler("onClientPreRender",root, boladona) 
setWaveHeight ( 0 ) 
setHeatHaze ( 0 ) 
    nextMapSet(false) 
    --addEventHandler("onClientRender",getRootElement(),drawRadarS) 
  
                showPlayerHudComponent ("radar",true) 
            showPlayerHudComponent ("crosshair",true) 
    fadeCamera(true) 
    showHUD(false) 
     
    g_Vehicle = vehicle 
    setVehicleDamageProof(g_Vehicle, true) 
    OverrideClient.updateVars(g_Vehicle) 
     
    --local x, y, z = getElementPosition(g_Vehicle) 
    setCameraBehindVehicle(vehicle) 
    --alignVehicleToGround(vehicle) 
    updateVehicleWeapons() 
    setCloudsEnabled(g_GameOptions.cloudsenable) 
    setBlurLevel(g_GameOptions.blurlevel) 
    g_dxGUI.mapdisplay:visible(g_GameOptions.showmapname) 
    if engineSetAsynchronousLoading then 
        engineSetAsynchronousLoading( g_GameOptions.asyncloading ) 
    end 
string.gsub(mapName, "[old]", "[OLDS]") 
    g_dxGUI.mapdisplay:text("#a0ff00Map: #ffffff"..g_MapInfo.name) 
  
  

Posted

string library have some special characters call'd "magic characters" : ( ) . % + - * ? [ ^ $

So when you are using "string.gsub(mapName, "[old]", "[OLDS]")" then "[]" are seend as magic characters and not as a character.

To make string.gsub to use this "magic characters" as normal characters you need to put in front of them a "%".

  
string.gsub(mapName, "%[old%]", "[OLDS]") 
  

Posted
no problem.

also they're not called magic characters, they're called special characters

Then please go and tell to the LUA dev's that they write it wrong on the lua.org

http://www.lua.org/pil/20.2.html

Some characters, called magic characters, have special meanings when used in a pattern. The magic characters are 
  
    ( ) . % + - * ? [ ^ $ 

  • MTA Team
Posted

Whoah, keep your offense down! By the way, the Lua dev's didn't create the PIL, iirc.

still called special characters, magic characters are for the stupid

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...