Thread: replacetext()
View Single Post
  #10  
Old 06-19-2009, 04:32 PM
Cubes Cubes is offline
Registered User
Cubes's Avatar
Join Date: Dec 2005
Location: Chesapeake, Virginia
Posts: 498
Cubes is a jewel in the roughCubes is a jewel in the rough
I cannot for the life of me get this to work serverside. I was trying to use it to replace text in a .gmap file. If I trigger serverside -> clientside ->serverside it works but it lags the client for a moment.

PHP Code:
function onActionServerside()
{
  if(
params[0] = "test")
  {
    
temp.testload.loadlines("levels/gmap/temptest.gmap");
    
temp.testload2 replacetext(temp.testload"rofltest""loltest");
    
temp.testload2.savelines("levels/gmap/lolxdd.gmap"0);
  }
}
function 
replacetext(txt,a,b) {
  if (
txt.pos(a)<0)
    return 
txt;
  
temp.txtpos txt.positions(a);
  
temp.newtxt txt.substring(0,txtpos[0]);
  for (
temp.i=0;i<txtpos.size();i++)
  {
    
newtxt @= b;
    
newtxt @= txt.substring(txtpos[i]+a.length(),txt.substring(txtpos[i]+a.length()).pos(a));
  }
  return 
newtxt;
}

//#CLIENTSIDE
function onPlayerChats(){
  
temp.tokens player.chat.tokenize();
  switch(
temp.tokens[0])
  {
    case 
"test":
        
triggerserver("gui"name"test");
      break;
  }

Reply With Quote