Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Sonmez
1
Script Showroom / Re: Sonmez's New Chat System
« on May 17th, 11:18 AM »
Quote from MRSK143 on May 16th, 12:20 PM
Hey sonmez, how you have disabled the old chat box? i mean there wasn't showing any text of old box
There is no method to prevent the default chat to open but you can add return false; in onPlayerChat() in order to disable this function.
2
Script Showroom / Re: Sonmez's New Chat System
« on May 17th, 11:15 AM »
Quote from Sebastian on May 14th, 07:15 AM
Is it the same with the one from your server? :o
I remember it was a perfect alternative. Too bad we cannot actually force stop the default chat to open.


EDIT: Here is a video recorded when were testing it :D back in 2021-01-04-1256

https://youtu.be/bQRcEiZ9E2o
Hi Sebastian, it's been a long time I hope you're fine, and yes this chatbox is almost the same but unfortunately I lost my old files, and I had to reproduced them.
3
Script Showroom / Re: Sonmez's New Chat System
« on May 12th, 10:24 AM »
It seems you did not place the Font folder correctly thats why the letters are small. True location is store folder. It should have been "store/fonts". Also you can find "floor( 17 * GUI.GetScreenSize( ).Y / 1080 );" this code in 2 places of code. You can change "17" with any other value in order to change your font size.

I haven't tested it with Chinese characters, but it is necessary to add a Chinese font, and change "TR Tahoma Bold" with the font which contains Chinese letters. Each key contains a keycode. If the keycodes supported by vcmp are limited, we can support those keys which are not supported ​​with manually configuring the fonts by changing keycodes.
4
Code has been reproduced.
5
Script Showroom / Sonmez's New Chat System
« on May 10th, 08:38 AM »
As most of us know, the original chat in vcmp only supports English letters. So, I have created this custom chat system in order to use Turkish letters. It is also possible to bring support for different languages ​​by changing the font file.   

SERVER SIDE
Code: [Select]
function onClientScriptData( player ) {
  local int=Stream.ReadInt(), str=Stream.ReadString();
  local aColour = player.Colour, pcolor = format("[#%02X%02X%02X]", aColour.r, aColour.g, aColour.b);
  if(int==2022){for(local i = 0; i<100; i++){SendDataToClient(i, 2022, pcolor.tolower()+player.Name+": [#ffffff]"+str);}}
}

function SendDataToClient(p,i,s){
  p=FindPlayer(p);
  if(p){
    Stream.StartWrite();Stream.WriteInt(i);
  }
  if(s!=null){
    Stream.WriteString(s);
  }
  Stream.SendStream(p);
}


CLIENT SIDE
Code: [Select]
// =================== Credits Goes To ysc3839 for Client Timer ==============================
function Script::ScriptProcess(){
  Timer.Process();
}

Timer <- {
 Timers = {}

 function Create(environment, listener, interval, repeat, ...)
 {
  // Prepare the arguments pack
  vargv.insert(0, environment);

  // Store timer information into a table
  local TimerInfo = {
   Environment = environment,
   Listener = listener,
   Interval = interval,
   Repeat = repeat,
   Args = vargv,
   LastCall = Script.GetTicks(),
   CallCount = 0
  };

  local hash = split(TimerInfo.tostring(), ":")[1].slice(3, -1).tointeger(16);

  // Store the timer information
  Timers.rawset(hash, TimerInfo);

  // Return the hash that identifies this timer
  return hash;
 }

 function Destroy(hash)
 {
  // See if the specified timer exists
  if (Timers.rawin(hash))
  {
   // Remove the timer information
   Timers.rawdelete(hash);
  }
 }

 function Exists(hash)
 {
  // See if the specified timer exists
  return Timers.rawin(hash);
 }

 function Fetch(hash)
 {
  // Return the timer information
  return Timers.rawget(hash);
 }

 function Clear()
 {
  // Clear existing timers
  Timers.clear();
 }

 function Process()
 {
  local CurrTime = Script.GetTicks();
  foreach (hash, tm in Timers)
  {
   if (tm != null)
   {
    if (CurrTime - tm.LastCall >= tm.Interval)
    {
     tm.CallCount++;
     tm.LastCall = CurrTime;

     tm.Listener.pacall(tm.Args);

     if (tm.Repeat != 0 && tm.CallCount >= tm.Repeat)
      Timers.rawdelete(hash);
    }
   }
  }
 }
};

// ============================================================================================

local sX = GUI.GetScreenSize().X,sY = GUI.GetScreenSize().Y;
chatbox <-{Box = null EditBox = null}

function Script::ScriptLoad(){
  createChatBox();
}

function Server::ServerData( stream ){
 local readint=stream.ReadInt( ),readstr=stream.ReadString( );
 switch(readint.tointeger()){
  case 2022: chatProcess(readstr); break;
 }
}

function GUI::InputReturn( editbox ){
  if (editbox == chatbox.EditBox){
      if (chatbox.EditBox.Text == "" || chatbox.EditBox.Text == " " || chatbox.EditBox.Text == " " ){
        chatbox.EditBox = null;
      }else{
        if (chatbox.EditBox.Text.len() < 97){
          SendDataToServer(chatbox.EditBox.Text, 2022);
        }chatbox.EditBox = null;
      }         
  }
}

chat_key <- KeyBind( 0x59 );
function KeyBind::OnDown(key){
  if (key == chat_key){
    if(!chatbox.EditBox){
      createChatEditBox();
    }
  }
}

function VScreen(pos_x, pos_y){//Credits goes to Doom_Kill3R for this function
 local
     screenSize = GUI.GetScreenSize( ),
     x = floor( pos_x * screenSize.X / 1920 ),
     y = floor( pos_y * screenSize.Y / 1080 );
  return VectorScreen( x, y );
}
function SendDataToServer(s, i){local msg=Stream();msg.WriteInt(i.tointeger());msg.WriteString(s);Server.SendData(msg);}


function createChatBox(){
  chatbox.Box = GUIMemobox(VScreen( 10 , 25 ), VScreen(1000, 400), Colour(0, 0, 0, 255), GUI_FLAG_MEMOBOX_TOPBOTTOM | GUI_FLAG_VISIBLE | GUI_FLAG_TEXT_TAGS);
  chatbox.Box.RemoveFlags( GUI_FLAG_BACKGROUND | GUI_FLAG_BORDER );
  chatbox.Box.FontSize = floor( 17 * GUI.GetScreenSize( ).Y / 1080 );
  chatbox.Box.FontName = "TR Tahoma Bold"
  chatbox.Box.FontFlags = GUI_FFLAG_OUTLINE;
  chatbox.Box.LineHeight = 0;
}

function createChatEditBox(){
    chatbox.EditBox = GUIEditbox(VScreen( 15, 370 ), VScreen( 900, 30 ), Colour(0, 0, 0, 255), GUI_FLAG_TEXT_TAGS);
    chatbox.EditBox.FontSize = floor( 17 * GUI.GetScreenSize( ).Y / 1080 );
    chatbox.EditBox.TextColour = Colour(255, 255, 255, 255);
    chatbox.EditBox.FontName = "TR Tahoma Bold"
    chatbox.EditBox.FontFlags = GUI_FFLAG_OUTLINE;
    chatbox.EditBox.RemoveFlags( GUI_FLAG_BACKGROUND | GUI_FLAG_BORDER );
chatbox.EditBox.Text = "";
chatboxTimer <- Timer.Create(this, function(text, int) {
      chatbox.EditBox.Text = "";
  GUI.SetFocusedElement( chatbox.EditBox );
    }, 45, 1, "Timer Text ", 12345);
}
chatTimer <- null;
maxChatLine <- 15;
function chatProcess(readstr){
  if (chatbox.Box.LineHeight == 0){chatbox.Box.LineHeight = 1;}
    chatbox.Box.AddLine(readstr, Colour(255, 255, 255, 255))
    if(chatbox.Box.LineHeight < maxChatLine ){
      chatbox.Box.LineHeight += 1;
    }
    chatTimerProcess();
}

function chatTimerProcess(){
    Timer.Destroy( chatTimer );
    chatTimer <- Timer.Create(this, function(text, int) {
    if (chatbox.Box.LineHeight > 0 ){
      chatbox.Box.LineHeight -=1;
    }
    chatbox.Box.DisplayPos = 0;
 }, 10000, 0, "Timer Text ", 12345);
}


You need add fonts folder to store.


New Chat Key Is -> "Y"

Preview:


Good luck...
6
Fine, What about you?
Updated btw ;D
7
Script Showroom / Re: Sonmez's Vehicle System
« on July 17th, 2021, 11:10 AM »
Code has been reproduced
8
Script Showroom / Re: Auto Mute System (Update v1.0)
« on July 17th, 2021, 02:47 AM »
Code has been updated
9
Code has been reproduced
10
Snippet Showroom / Re: Basic Near Player Chat For RP Servers
« on April 10th, 2021, 11:31 PM »
I recompiled the code. Added /s command for shouting. And still standard chat = nearplayer chat.
11
Script Showroom / Re: Sonmez's Register & Ban & Admin System
« on February 4th, 2021, 12:50 PM »
Quote from Athanatos on February 3rd, 2021, 03:22 PM
> sees SupportedChars()
-> Flashbacks with me watching my classmate's C++ code
I am using Turkish chars from SQL db with index like "local char1 = SQLstring;". So i need check it specially with if().
12
Script Showroom / Re: Sonmez's Register & Ban & Admin System
« on February 3rd, 2021, 02:25 PM »
Quote from Sebastian on February 3rd, 2021, 11:03 AM
Not hashing the passwords...
Updated
13
Script Showroom / Sonmez's Map Editor (Major Update v1.0)
« on January 13th, 2021, 09:53 PM »
v1.0 Release

Features
  • Controls are similar to Dizzasters map editor. (Because it is the most common editor.)
  • Added relative positioning mode.
  • Very simple and useful.
  • (For v1.0 Beta most features are disabled so you might need wait for updates.)

Controls
  • R - Resets object rotation.
  • Delete - Deletes an object selected.
  • Backspace - Stop controlling an object.
  • Object can be selected by shooting it once.

Commands

  • /editor - Enable or disable map editor.
  • /savemap  - Saves map.
  • /objectlist - Listing all created objects. (With editor)
  • /addobject - Listing all created objects.
  • /selectobject - Selects object with id.
  • /removeobject - Removes object with id.
  • /cloneobject - Clones an object selected.
  • Arrow keys - Movements and rotation.

SERVER SIDE

main.nut
Code: [Select]
function onScriptLoad(){
  dofile("scripts/editor.nut"); MonScriptLoad();
}

function onPlayerJoin(player){
    MonPlayerJoin(player);
}

function onClientScriptData( player ) { local int=Stream.ReadInt(), str=Stream.ReadString();
  if (int == 939381){onNewKeyUp(player,str)} else if (int == 939382){onNewKeyDown(player,str)}
}

function onNewKeyUp(player,key){MonKeyUp(player,key)}

function onNewKeyDown(player,key){MonKeyDown(player,key)}

function onPlayerCommand(player,cmd,text){
    MonPlayerCommand(player,cmd,text);
}

function onObjectShot( object, player, weapon ){MonObjectShot( object, player, weapon )}

function find(str,string){if(string.find(str)!= null){return true;}else{return false;}}

function FindAndReplace(string,findString,Replace){
  if (find(findString,string)&&findString!=string){ local n=-1;
    do{n++
      if(n+findString.len()<=string.len()){
        if(string.slice(n,n+findString.len())==findString){ local prev=null,next=null;
          if(n==0){prev="";}else{prev=string.slice(0,n)}
          if(n+Replace.len()==string.len()){next=""}else{next=string.slice(n+findString.len(),string.len())}
          string = format("%s%s%s"prev,Replace,next); n=string.len()+1;
          return string;
        }
      }
    }while (n<string.len())
  }else{return string;}
}

function GetTok(string, separator, n, ...){
  local m = vargv.len() > 0 ? vargv[0] : n,tokenized = split(string, separator),text = "";
  if (n > tokenized.len() || n < 1) return null;
  for (; n <= m; n++){text += text == "" ? tokenized[n-1] : separator + tokenized[n-1];}return text;
}

function NumTok( string, separator){local tokenized = split(string, separator); return tokenized.len();}


editor.nut
Code: [Select]
class MapEditor{ editing=false; reposition=true; selectedobj=null; speed=0.1; motion=null; motioning=false; }

function MonScriptLoad(){
  MapDB <- ConnectSQL( "MapDB.db" ); map <- array(GetMaxPlayers(), null); MapObjects <- "";
  QuerySQL(MapDB, "create table if not exists Map (List NUMERIC DEFAULT 0,Model NUMERIC DEFAULT 0,World NUMERIC DEFAULT 0,X TEXT, Y TEXT,Z TEXT,rX TEXT, rY TEXT,rZ TEXT, Alpha TEXT)");
  createMapObjects();
}

function MonPlayerJoin(player){ map[player.ID] = MapEditor(); }

function MonPlayerCommand(player,cmd,text){
  if (cmd=="cmds"||cmd=="commands"){
    MessagePlayer("[#3486eb](/) [#ffffff]editor, savemap, objectlist", player);
    MessagePlayer("[#3486eb](/) [#ffffff]addobject, removeobject, selectobject, cloneobject", player);
  }
  else if (cmd=="editor"){
    if (map[player.ID].editing == false){map[player.ID].editing = true; MessagePlayer("[#3486eb]# [#ffffff]Map editor mod enabled.", player);}
    else {map[player.ID].editing = false;  map[player.ID].selectedobj = null; MessagePlayer("[#3486eb]# [#ffffff]Map editor mod disabled.", player);}
  }
  else if (cmd=="savemap"){
    if (map[player.ID].editing == false){return false;}
    saveMapObjects()
  }
  else if (cmd=="objectlist"){ local list=""
    for (local i = 0; i < GetObjectCount()+1; i++){
      if (GetTok(MapObjects, ",", i)){
        local object = FindObject(GetTok(MapObjects,",",i).tointeger());
        if (object){if (list == ""){list = "[#34e5eb]ID: [#ffffff]"+object.ID}else{list = list+", [#34e5eb]ID: [#ffffff]"+object.ID}}
      }
    }text = "[#3486eb]|Object List| ";MessagePlayer("[#3486eb]# [#ffffff]"+text, player);MessagePlayer("[#3486eb]# [#ffffff]"+list, player);
  }
  else if (cmd=="addobject"){
    if (map[player.ID].editing == false){return false;}
    if (!text){MessagePlayer("[#3486eb]# [#ffffff]You must enter numeric value for object model.", player);}
    if (IsNum(text)){
      local model = text.tointeger(), world = player.World,pos = player.Pos,alpha = 255,ObjID = CreateObject( model, world, pos, alpha ).ID;
      FindObject(ObjID).TrackingShots = true; addMapObject(ObjID); map[player.ID].selectedobj = FindObject(ObjID);
      MessagePlayer("[#3486eb]# [#ffffff]Object with model number "+model+" created. ID: "+ObjID+"", player);
      MessagePlayer("[#3486eb]# [#ffffff]Selected object with id:"+ObjID+"", player);
    }
    else{MessagePlayer("[#3486eb]# [#ffffff]You must enter numeric value for object model.", player);}
  }
  else if (cmd=="removeobject"){
    if (map[player.ID].editing == false){return false;}
    if (!text){MessagePlayer("[#3486eb]# [#ffffff]You must enter numeric value for object ID.", player);}
    if (!IsNum(text)){MessagePlayer("[#3486eb]# [#ffffff]You must enter numeric value for object ID.", player); return false;}
    if (FindObject(text.tointeger())){deleteMapObject(text.tointeger());}
    MessagePlayer("[#3486eb]# [#ffffff]Object with id: "+text+" deleted", player);
  }
  else if (cmd=="selectobject"){
    if (map[player.ID].editing == false){return false;}
    if (!text){MessagePlayer("[#3486eb]# [#ffffff]You must enter numeric value for object ID.", player);}
    if (!IsNum(text)){MessagePlayer("[#3486eb]# [#ffffff]You must enter numeric value for object ID.", player); return false;}
    local obj = FindObject(text.tointeger());
    local found = 989898;for (local i = 0; i < 100; i++){local plr = FindPlayer(i); if (plr){if (map[plr.ID].selectedobj == obj){found = i;}}}
    if (found == true){MessagePlayer("[#3486eb]# [#ffffff]"+FindPlayer(found.tointeger).Name+" is using this object now. Select another one.", player); return false;}
    if (obj){ map[player.ID].selectedobj = obj;
    MessagePlayer("[#3486eb]# [#ffffff]Selected object with id:"+text+"", player);
    }else{MessagePlayer("[#3486eb]# [#ffffff]ID: "+text+" not found. Try with another id.", player);}
  }
  else if (cmd=="cloneobject"){
    if (map[player.ID].editing == false){return false;}
    if (map[player.ID].selectedobj){local object = map[player.ID].selectedobj;
      local model = object.Model, world = object.World,pos = object.Pos,alpha = 255,ObjID = CreateObject( model, world, pos, alpha ).ID;
      FindObject(ObjID).TrackingShots = true; addMapObject(ObjID); map[player.ID].selectedobj = FindObject(ObjID);
      map[player.ID].selectedobj = FindObject(ObjID);
      MessagePlayer("[#3486eb]# [#ffffff]Cloned object " + text + " at its position", player);
      MessagePlayer("[#3486eb]# [#ffffff]Selected object with id:"+ObjID+"", player);
    }
  }
  else{
    MessagePlayer("[#3486eb]# [#ffffff]''"+cmd+"'' command not found. Use /cmds or /commands to see all commands.", player)
  }
}
function MonObjectShot( object, player, weapon ){
  if (map[player.ID].editing == true){
    local found = false;
    for (local i = 0; i < 100; i++){local plr = FindPlayer(i); if (plr){if (map[plr.ID].selectedobj == object){found = true;}}}
    if (found == true) return false;
    MessagePlayer("[#3486eb]# [#ffffff]Selected object with id:"+object.ID+"", player)
    map[player.ID].selectedobj = object;
  }
}

function speedUP(player){
  switch(map[player.ID].speed){
    case 0.1: map[player.ID].speed = 0.6; MessagePlayer("[#3486eb]# [#ffffff]Movement speed is: NORMAL",player); break;
    case 0.6: map[player.ID].speed = 1.1; MessagePlayer("[#3486eb]# [#ffffff]Movement speed is: FAST",player); break;
    case 1.1: map[player.ID].speed = 1.6; MessagePlayer("[#3486eb]# [#ffffff]Movement speed is: VERY FAST",player); break;
    case 1.6: MessagePlayer("[#3486eb]# [#ffffff]Movement speed is: VERY FAST",player); break;
  }
}
function speedDOWN(player){
  switch(map[player.ID].speed){
    case 0.1: MessagePlayer("[#3486eb]# [#ffffff]Movement speed is: SLOW",player); break;
    case 0.6: map[player.ID].speed = 0.1; MessagePlayer("[#3486eb]# [#ffffff]Movement speed is: SLOW",player); break;
    case 1.1: map[player.ID].speed = 0.6; MessagePlayer("[#3486eb]# [#ffffff]Movement speed is: NORMAL",player); break;
    case 1.6: map[player.ID].speed = 1.1; MessagePlayer("[#3486eb]# [#ffffff]Movement speed is: FAST",player); break;
  }
}
function PUP(player,object){
  if (map[player.ID].reposition == true){object.Pos.z += map[player.ID].speed;}
  else{object.RotateByEuler( Vector( map[player.ID].speed, 0, 0 ), 100 );}
}
function PDOWN(player,object){
  if (map[player.ID].reposition == true){object.Pos.z -= map[player.ID].speed;}
  else{object.RotateByEuler( Vector( -map[player.ID].speed, 0, 0 ), 100 );}
}
function UP(player,object){
  if (map[player.ID].reposition == true){
  local rel = calculateAngle(player);
    switch(rel){
      case 1: object.Pos.x -= map[player.ID].speed; break;
      case 2: object.Pos.y -= map[player.ID].speed; break;
      case 3: object.Pos.y += map[player.ID].speed; break;
      case 4: object.Pos.x += map[player.ID].speed; break;
      case 5: object.Pos.y -= map[player.ID].speed; break;
      case 6: object.Pos.y += map[player.ID].speed; break;
    }
  }else{object.RotateByEuler( Vector( 0, map[player.ID].speed, 0 ), 100 );}
}
function DOWN(player,object){
  if (map[player.ID].reposition == true){
  local rel = calculateAngle(player);
    switch(rel){
      case 1: object.Pos.x += map[player.ID].speed; break;
      case 2: object.Pos.y += map[player.ID].speed; break;
      case 3: object.Pos.y -= map[player.ID].speed; break;
      case 4: object.Pos.x -= map[player.ID].speed; break;
      case 5: object.Pos.y += map[player.ID].speed; break;
      case 6: object.Pos.y -= map[player.ID].speed; break;
    }
  }else{object.RotateByEuler( Vector( 0, -map[player.ID].speed, 0 ), 100 );}
}
function RIGHT(player,object){
  if (map[player.ID].reposition == true){
  local rel = calculateAngle(player);
    switch(rel){
      case 1: object.Pos.y -= map[player.ID].speed; break;
      case 2: object.Pos.x += map[player.ID].speed; break;
      case 3: object.Pos.x -= map[player.ID].speed; break;
      case 4: object.Pos.y += map[player.ID].speed; break;
      case 5: object.Pos.x += map[player.ID].speed; break;
      case 6: object.Pos.x -= map[player.ID].speed; break;
    }
  }else{object.RotateByEuler( Vector( 0, 0, map[player.ID].speed ), 100 );}
}
function LEFT(player,object){
  if (map[player.ID].reposition == true){
  local rel = calculateAngle(player);
    switch(rel){
      case 1: object.Pos.y += map[player.ID].speed; break;
      case 2: object.Pos.x -= map[player.ID].speed; break;
      case 3: object.Pos.x += map[player.ID].speed; break;
      case 4: object.Pos.y -= map[player.ID].speed; break;
      case 5: object.Pos.x -= map[player.ID].speed; break;
      case 6: object.Pos.x += map[player.ID].speed; break;
    }
  }else{object.RotateByEuler( Vector( 0, 0, -map[player.ID].speed ), 100 );}
}

function calculateAngle(player){
  local a = player.Angle;
  if (a > 0){if (0.8 < a && a < 2.4){return 1;}else{if (a > 2.4){return 2;}else if (a < 0.8){return 3;}}}
  else{if (-2.4 < a && a < -0.8){return 4;}else{if (-2.4 > a){return 5;}else if (-0.8 < a){return 6;}}}
}

function MonKeyUp(player,key){
  if (map[player.ID].motion != null){ map[player.ID].motion.Delete(); map[player.ID].motion = null;}
}
function MonKeyDown(player,key){
  if ( typeof player != "instance" ){player = FindPlayer(player); if (!player){return false}}
  if (map[player.ID].editing == true && map[player.ID].selectedobj != null){
    local obj = FindObject(map[player.ID].selectedobj.ID);
    switch (key)
    {
      case "Up": UP(player,obj); break;
      case "Down": DOWN(player,obj); break;
      case "Right": LEFT(player,obj); break;
      case "Left": RIGHT(player,obj); break;
      case "PUp": PUP(player,obj); break;
      case "PDown": PDOWN(player,obj); break;
      case "R":
        obj.RotateToEuler( Vector( 0, 0, 0 ), 0 );
        MessagePlayer( "[#3486eb]# [#ffffff]Rotation angles have been reset", player );
      break;
      case "One":
        switch(map[player.ID].speed){
          case 0.1:
            map[player.ID].speed = 0.6;
            MessagePlayer("[#3486eb]# [#ffffff]Movement speed is: NORMAL",player);
          break;
          case 0.6:
            map[player.ID].speed = 1.1;
            MessagePlayer("[#3486eb]# [#ffffff]Movement speed is: FAST",player);
          break;
          case 1.1:
            map[player.ID].speed = 1.6;
            MessagePlayer("[#3486eb]# [#ffffff]Movement speed is: VERY FAST",player);
          break;
          case 1.6:
            map[player.ID].speed = 0.1;
            MessagePlayer("[#3486eb]# [#ffffff]Movement speed is: SLOW",player);
          break;
        }
      break;
      case "Two":
      if (map[player.ID].reposition == true){map[player.ID].reposition=false;
        MessagePlayer("[#3486eb]# [#ffffff]Positioning mode closed. Rotating mode opened.", player);
      }else{map[player.ID].reposition=true;
        MessagePlayer("[#3486eb]# [#ffffff]Positioning mode opened. Rotating mode closed.", player);
      }
      break;
      case "Delete":
        deleteMapObject(obj.ID);
        MessagePlayer("[#3486eb]# [#ffffff]Object has been removed",player);
        map[player.ID].selectedobj = null;
      break;
      case "BackSpace":
        map[player.ID].selectedobj = null;
        MessagePlayer("[#3486eb]# [#ffffff]You have finished editing the object",player);
      break;
    }
    if (key == "Up" || key == "Down" || key == "Right" || key == "Left" || key == "PUp" || key == "PDown"){
      if (map[player.ID].motion == null){map[player.ID].motion = NewTimer("MonKeyDown", 100, 0, player.ID,key);}
    }
  }
}

function createMapObjects(){
  for (local i = 0; i < 5000; i++){
    local q = QuerySQL(MapDB, "SELECT * FROM Map WHERE List = '" + i + "'");
    if (q){
      local list = GetSQLColumnData(q, 0).tointeger(),
      model = GetSQLColumnData(q, 1).tointeger(),
      world = GetSQLColumnData(q, 2).tointeger(),
      X = GetSQLColumnData(q, 3).tofloat(),
      Y = GetSQLColumnData(q, 4).tofloat(),
      Z = GetSQLColumnData(q, 5).tofloat(),
      rX = GetSQLColumnData(q, 6).tofloat(),
      rY = GetSQLColumnData(q, 7).tofloat(),
      rZ = GetSQLColumnData(q, 8).tofloat(),
      alpha = GetSQLColumnData(q, 9).tointeger(),
      pos = Vector(X,Y,Z);
      CreateObject( model, world, pos, alpha );
      local ObjID = GetObjectCount()-1;
      FindObject(ObjID).TrackingShots = true;
      FindObject(ObjID).RotateToEuler(Vector(rX,rY,rZ),0);
      addMapObject(ObjID) 
    }
  }
}

function addMapObject(ObjID){
  if (MapObjects == ""){MapObjects = ObjID.tostring();}
  else{MapObjects = MapObjects+","+ObjID;}
}

function deleteMapObject(ObjID){
  ObjID = ObjID.tointeger()
  local object = FindObject(ObjID);
  if (object){
    if (find(","+ObjID,MapObjects)){MapObjects = FindAndReplace(MapObjects,","+ObjID,"");}
    else if (find(ObjID+",",MapObjects)){MapObjects = FindAndReplace(MapObjects,ObjID+",","");}
    else{MapObjects = "";}
    object.Delete()
  }
}

function saveMapObjects(){
  QuerySQL(MapDB,"DELETE FROM Map"); local a = 0;
  for (local i = 0; i < GetObjectCount()+1; i++){
    if (GetTok(MapObjects, ",", i)){
      local object = FindObject(GetTok(MapObjects,",",i).tointeger());
      if (object){
        QuerySQL(MapDB, "INSERT INTO Map (List, Model, World , X, Y, Z, rX ,rY,rZ, Alpha) VALUES ( '"
        + a + "','"
        + object.Model + "','"
        + object.World + "','"
        + object.Pos.x + "','"
        + object.Pos.y + "','"
        + object.Pos.z + "','"
        + object.RotationEuler.x + "','"
        + object.RotationEuler.y + "','"
        + object.RotationEuler.z + "','"
        + object.Alpha + "' )");
        a++;
      }
    }
  }
  if (a == 0){Message("[#3486eb]# [#ffffff]Database has been reset.");}
  else{Message("[#3486eb]# [#ffffff]"+a+" object saved to database.");}
}



CLIENT SIDE

main.nut
Code: [Select]
local Enter = KeyBind( 0x0D );
local BackSpace = KeyBind( 0x08 );
local Shift = KeyBind( 0x10 );
local Delete = KeyBind(0x2E);
local Up = KeyBind(0x26);
local Down = KeyBind(0x28);
local Left = KeyBind(0x25);
local Right = KeyBind(0x27);
local PUp = KeyBind(0x21);
local PDown = KeyBind(0x22);
local One = KeyBind(0x31);
local Two = KeyBind(0x32);
local I = KeyBind(0x49);
local L = KeyBind(0x4C);
local R = KeyBind(0x52);
function KeyBind::OnUp(key){
  switch(key){
    case Enter: SendDataToServer("Enter", 939381); break;
    case BackSpace: SendDataToServer("BackSpace", 939381); break;
    case Shift: SendDataToServer("Shift", 939381); break;
    case Delete: SendDataToServer("Delete", 939381); break;
    case Up: SendDataToServer("Up", 939381); break;
    case Down: SendDataToServer("Down", 939381); break;
    case Left: SendDataToServer("Left", 939381); break;
    case Right: SendDataToServer("Right", 939381); break;
    case PUp: SendDataToServer("PUp", 939381); break;
    case PDown: SendDataToServer("PDown", 939381); break;
    case One: SendDataToServer("One", 939381); break;
    case Two: SendDataToServer("Two", 939381); break;
    case I: SendDataToServer("I", 939381); break;
    case L: SendDataToServer("L", 939381); break;
    case R: SendDataToServer("R", 939381); break;
  }
}

function KeyBind::OnDown(key){
  switch(key){
    case Enter: SendDataToServer("Enter", 939382); break;
    case BackSpace: SendDataToServer("BackSpace", 939382); break;
    case Shift: SendDataToServer("Shift", 939382); break;
    case Delete: SendDataToServer("Delete", 939382); break;
    case Up: SendDataToServer("Up", 939382); break;
    case Down: SendDataToServer("Down", 939382); break;
    case Left: SendDataToServer("Left", 939382); break;
    case Right: SendDataToServer("Right", 939382); break;
    case PUp: SendDataToServer("PUp", 939382); break;
    case PDown: SendDataToServer("PDown", 939382); break;
    case One: SendDataToServer("One", 939382); break;
    case Two: SendDataToServer("Two", 939382); break;
    case I: SendDataToServer("I", 939382); break;
    case L: SendDataToServer("L", 939382); break;
    case R: SendDataToServer("R", 939382); break;
  }
}
function SendDataToServer(s, i){local msg=Stream();msg.WriteInt(i.tointeger());msg.WriteString(s);Server.SendData(msg);}


    Update Notes:
    • Code has been reproduced
    • Added more features
    • Added client side key event to server side key event
    • Bug fixes
14
Snippet Showroom / New Custom Event onPlayerUnderAttack
« on January 13th, 2021, 11:36 AM »
Syntax
function onPlayerUnderAttack(player,plr)

Example
Code: [Select]
function onPlayerUnderAttack(player,plr)
{
  Message(player.Name+" is attacking "+plr.Name);
}

Source Code

CLIENT SIDE
Code: [Select]
function Player::PlayerShoot(player, weapon, hitEntity, hitPosition)
{
  if (player == World.FindLocalPlayer()){
  if (hitEntity.Type == 0){
      local shooter = player;
      local plr = hitEntity.ID;
      local message = Stream();
      message.WriteInt(12332115);  // use unique integer
      message.WriteString(plr.tostring());
      Server.SendData(message);}
}}


SERVER SIDE

Code: [Select]
function onPlayerUnderAttack(player,plr)
{
  Message(player.Name+" is attacking "+plr.Name);
}
function onClientScriptData( player )
{
    local int = Stream.ReadInt(),
    string = Stream.ReadString();
    if (int == 12332115)
    {
      local plr = FindPlayer(string.tointeger());
      if (plr){onPlayerUnderAttack(player,plr)}
    }
}
15
Snippet Showroom / Re: FindAndReplace (New Custom Functions)
« on January 12th, 2021, 09:13 AM »
Quote from DizzasTeR on January 12th, 2021, 04:12 AM
Quote from |VC-TR| Yankee on January 11th, 2021, 06:46 PM
That's the way it's done.
Code: [Select]
function onPlayerChat(player, text)
{
    if(text.find("YourWord") != null)
        text = StringGSub(text, "YourWord", "ReplacedWord");
}
Code: [Select]
function StringGSub(str, findString, replace)
{
    local index;
    do {
        index = str.find(findString, index != null ? index+findString.len() : 0);
        if (index != null)
        {
            local prev = str.slice(0, index);
            local next = str.slice(index+findString.len(), str.len());
            str = format("%s%s%s", prev, replace, next);
        }
    } while (index != null);
    return str;
}
This is a good alternative but i think my code is easier to understand and appeal to everyone.