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.

Topics - umar4911
61
Scripting and Server Management / play sound on fire
« on October 22nd, 2017, 12:49 PM »
I have added a custom weapon. What will be the function to play sound on fire??
62
Scripting and Server Management / /slap cmd Gettok arguments
« on October 22nd, 2017, 05:38 AM »
I have made many commands in my server. The problem I am facing is with getTok.
See this as an example
Code: [Select]
else if(cmd == "slap")
{
if(status[player.ID].Level < 3) MessagePlayer("[#FFDD33]Information:[#FFFFFF] Unauthorized Access", player);
else if(!arguments) MessagePlayer("[#FFDD33]Command Error:[#FFFFFF] Use /" + cmd + " [plr] [Reason]", player);
else if(NumTok(arguments, " ") < 2) MessagePlayer("[#FFDD33]Command Error:[#FFFFFF] Use /" + cmd + " [plr] [Reason]", player);
else
{
local plr = FindPlayer(GetTok(arguments, " ", 1));
if(!plr) MessagePlayer("[#FFDD33]Usage Error:[#FFFFFF] Invalid Player", player);
else if(status[player.ID].Level < status[plr.ID].Level) MessagePlayer("[#FFDD33]Usage Error:[#FFFFFF] You cannot give any admin higher than you", player);
else
{
plr.Pos = Vector(plr.Pos.x, plr.Pos.y, plr.Pos.z + 5);
local reas = GetTok(arguments, " ", 2);
Message("[#FFDD33]Administrator Command:[#FFFFFF] Admin[" + player.Name + "] slapped player : " + plr.Name + " Reason : " + reas + ".");
}
}
}
The syntax of this code is: /cmd player reason. When I type the reason suppose I typed Spawn killing, it will only type spawn as reason. How to make it correct.
63
Scripting and Server Management / Player Immunity/Spawn Protection
« on October 16th, 2017, 12:17 PM »
I was making spawn protection.
I added this onplayerspawn
Code: [Select]

player.Immunity = 31;
MessagePlayer("Spawn Protection Enabled", player);
NewTimer("visibility", 5000, 1, player.ID);


Function
Code: [Select]
function visibility(player)
{
player.Immunity = 0;
MessagePlayer("Spawn Protection Disabled", player);
}

Error
Code: [Select]
An error has occured[trying to set in integer]
64
Scripting and Server Management / Gotoloc easy fix
« on October 7th, 2017, 07:15 AM »
I was making my gotoloc and encountered a small problem. Please fix it.
I am a little weak in making functions
onplayercommand
Code: [Select]
else if(cmd == "gotoloc")
{
if(!arguments) MessagePlayer("Wrong Syntax. Use /" + cmd + " <Name> ", player);
else
{
local q = QuerySQL(tele, "SELECT * FROM Locations WHERE Name = '" + arguments + "'");
if(!q) MessagePlayer("Location does not exist.", player);
else
{
player.IsFrozen = true;
NewTimer("gotoloc", 1000, 1, arguments, player);
local plr = GetSQLColumnData(q, 1);
MessagePlayer("You are being teleported to location: " + arguments + " made by: " + plr + ".", player);

}


}
}
 
 


function
Code: [Select]
function gotoloc(player, arguments )
{
local q = QuerySQL(tele, "SELECT * FROM Locations WHERE Name = '" + arguments +"'");
if(q)
{
xaxis = GetSQLColumnData(q, 2);
yaxis = GetSQLColumnData(q, 3);
zaxis = GetSQLColumnData(q, 4);

player.Pos = Vector(xaxis, yaxis, zaxis);
player.IsFrozen = false;
}



}

65
Snippet Showroom / Spawnloc System
« on October 6th, 2017, 06:32 PM »
I made a spawnloc system. My friend also wanted it so I thought to post it.

add this onScriptLoad()
(click to show/hide)
Code: [Select]
tele <- ConnectSQL( "databases/teleport.db" );
QuerySQL( tele, "CREATE TABLE IF NOT EXISTS spawn ( Autospawn TEXT, xaxis VARCHAR(25), yaxis VARCHAR(25), zaxis VARCHAR(25), Name VARCHAR(32) )" );




function onPlayerCommand(player, command, arguments)
(click to show/hide)
Code: [Select]
if(cmd == "setspawnloc")
 {
  local q = QuerySQL(tele, "SELECT * FROM spawn WHERE Name = '" + player.Name + "'");
  if(!q)
  {
   QuerySQL(tele, "INSERT INTO spawn ( Autospawn, xaxis, yaxis, zaxis, Name ) VALUES ( 'true' , '" + player.Pos.x + "' , '" + player.Pos.y + "' , '" + player.Pos.z + "', '" + player.Name + "' ) ");
  }
  else
  {
   QuerySQL(tele, "UPDATE spawn SET xaxis = '" + player.Pos.x + "' WHERE Name = '" + player.Name + "'");
   QuerySQL(tele, "UPDATE spawn SET yaxis = '" + player.Pos.y + "' WHERE Name = '" + player.Name + "'");
   QuerySQL(tele, "UPDATE spawn SET zaxis = '" + player.Pos.z + "' WHERE Name = '" + player.Name + "'");
   QuerySQL(tele, "UPDATE spawn SET Autospawn = 'true' WHERE Name = '" + player.Name + "'");
   MessagePlayer("Your spawnloc is updated and set to true. To disable it, use /spawnloc false", player);

  }
 }
 
 else if(cmd == "spawnloc")
 {
  if(!arguments) MessagePlayer("Error Unknown Syntax. Use /" + cmd + " <true/false>", player);
  local q = QuerySQL(tele, "SELECT * FROM spawn WHERE Name = '" + player.Name + "'");
  if(!q)
  {
   MessagePlayer("You didnot set any spawn location. Use /setspawnloc to set spawn location.", player);
  }
  else
  {
   if(arguments == "true")
   {
    QuerySQL(tele, "UPDATE spawn SET Autospawn = 'true' WHERE Name = '" + player.Name + "'");
   }
   if(arguments == "false")
   {
    QuerySQL(tele, "UPDATE spawn SET Autospawn = 'false' WHERE Name = '" + player.Name + "'");
   }
   // if(!arguments == "true", "false")
   else {
    MessagePlayer("Error Unknown Syntax. Use /" + cmd + " <true/false>", player);
   }
  }
 }
 



function onPlayerSpawn(player)
(click to show/hide)
Code: [Select]
function onPlayerSpawn(player)
{
local q = QuerySQL(tele, "SELECT * FROM spawn WHERE Name = '" + player.Name + "'");
if( q && GetSQLColumnData(q, 0) == "true" )
{
local
xspawn = GetSQLColumnData(q, 1).tointeger(),
yspawn = GetSQLColumnData(q, 2).tointeger(),
zspawn = GetSQLColumnData(q, 3).tointeger();

player.Pos = Vector(xspawn, yspawn, zspawn);
MessagePlayer("You are Spawned at your saved location", player);
}
else
MessagePlayer("You are spawned", player);
}
66
Scripting and Server Management / Where to put the code??
« on September 26th, 2017, 10:50 AM »
I made a spawnloc system. It contain a easy error which was fixed.
Spawnloc system
ok I need to know how to make the person spawn at his saved position.
67
Script and Content Requests / New scripts
« on September 22nd, 2017, 06:42 PM »
Guys, I added tons of cmds in my server. Yesterday, due to some virus, my windows got deleted. I reintalled it and tried to recover my server but I failed. Now I had to script it again. Can you please give me basic cmds for my server.
68
Scripting and Server Management / Easy error fix!
« on September 22nd, 2017, 10:33 AM »
I was making spawnloc and setspawnloc cmds with database. I know there is  a simple error but I am unable to find that.
onscript load
Code: [Select]

sploc <- ConnectSQL("databases/spawnloc.db");
QuerySQL( sploc, "CREATE TABLE IF NOT EXISTS spawn ( Name VARCHAR(32), Autospawn TEXT, xaxis VARCHAR(25), yaxis VARCHAR(25), zaxis VARCHAR(25) )" );
 print("spawnloc system loaded");

playercmds
Code: [Select]
if(cmd == "setspawnloc")
{
local q = QuerySQL(sploc, "SELECT * FROM spawn WHERE Name = '" + player.name + "'");
if(!q)
{
QuerySQL(sploc, "INSERT INTO spawn ( Name, Autospawn, xaxis, yaxis, zaxis ) VALUES ( '" + player.name + "' , 'true' , '" + player.Pos.x + "' , '" + player.Pos.y + "' , '" + player.Pos.z + "') ");
}
else
{
QuerySQL(sploc, "UPDATE spawn SET xaxis = '" + player.Pos.x + "' WHERE Name = '" + player.name + "'");
QuerySQL(sploc, "UPDATE spawn SET yaxis = '" + player.Pos.y + "' WHERE Name = '" + player.name + "'");
QuerySQL(sploc, "UPDATE spawn SET zaxis = '" + player.Pos.z + "' WHERE Name = '" + player.name + "'");
QuerySQL(sploc, "UPDATE spawn SET autospawn = 'true' WHERE Name = '" + player.name + "'");
MessagePlayer("Your spawnloc is updated and set to true. To disable it, use /spawnloc false", player);

}
}
 
if(cmd == "spawnloc")
{
// arguments = arguments.tolower();
if(!arguments) MessagePlayer("Error Unknown Syntax. Use /" + cmd + " <true/false>", player);
local q = QuerySQL(sploc, "SELECT * FROM spawn WHERE Name = '" + player.name + "'");
if(!q)
{
MessagePlayer("You didnot set any spawn location. Use /setspawnloc to set spawn location.", player);
}
else
{
if(arguments == "true")
{
QuerySQL(sploc, "UPDATE spawn SET autospawn = 'true' WHERE Name = '" + player.name + "'");
}
if(arguments == "false")
{
QuerySQL(sploc, "UPDATE spawn SET autospawn = 'true' WHERE Name = '" + player.name + "'");
}
/* if(!arguments == "true", "false")
{
MessagePlayer("Error Unknown Syntax. Use /" + cmd + " <true/false>", player);
} */
}
}
 
69
Scripting and Server Management / Divide the main.nut file
« on September 17th, 2017, 09:39 AM »
My code is on thousands of lines and tons of cmds. Can playercmds and function divided into other .nut files or not
70
First of all. Sorry for spamming the forum.
Plz fix the following scripts
This is the location script.
(click to show/hide)
Code: [Select]
function onScriptLoad()
{
 locations <- ConnectSQL( "databases/locations.db");
 print("Locations loaded.");
}





Code: [Select]
function onPlayerCommand(player, command, arguments)
{
 
if(cmd == "saveloc")
{
if(!arguments) MessagePlayer("Use /" + cmd + " <Name>", player);
else
{
local q = QuerySQL(locations, "SELECT * FROM location WHERE Name = '" + escapeSQLString(arguments) +"' ");
if(!q)
{
// Name of the location
// Name of the player who saved it
// it's axis
QuerySQL(locations, "INSERT INTO location ( Name, Made, Pos ) VALUES ('" + arguments(string) + "', '" + player.Name + "', '" + escapeSQLString(player.Pos) "')");
MessagePlayer("[#CCFF66]** Location saved. Use /gotoloc " + arguments + ".", player);
}
}




}




if(cmd == "gotoloc")
{
if(!text) MessagePlayer("Use /" + cmd + " <Name>", player);
else
{

local q = QuerySQL(locations, "SELECT * FROM location WHERE Name = '" + escapeSQLString(arguments) + "'");
local
x = GetSQLColumnData( q, 0), // name of the location
y = GetSQLColumnData( q, 1), // name of the player
z = GetSQLColumnData( q, 2), // axis
MessagePlayer("[#CCFF66]** You have been teleported to location: " + x + " Made By: " + y + ".", player);


}
}


}

 
 


SetHP
(click to show/hide)
Code: [Select]
  function onPlayerCommand(player, command, arguments)
{

 
if(cmd == "sethp")
{
if(!arguments) MessagePlayer("[#CCFF66]** Use /" + cmd + " <hp> <Name>", player);
else
{
local parm = split(arguments, " " );
local hp = parm[0], plr = FindPlayer(parm[1]);
if(!plr) MessagePlayer("[#CCFF66]** Invalid Player", player);
else
{
plr.Health = hp;
Message("[#CCFF66]** Your hp has been set to :" + hp + "by :" + Player.Name + ".", plr);
}
}
}
 

}


Can anybody give me the code of Set time and set weather. The code of set timer in wiki is wrong!!
71
Scripting and Server Management / Time, Weather and Heal
« on August 11th, 2017, 05:09 PM »
Can anybody give me the code of set time and weather? The time one in wiki is wrong


Please fix this code too.
Code: [Select]
function onPlayerCommand(player, command, arguments)
{
if(cmd == "heal")
{
local hp = player.Health;
if(hp == 100) Message("[#FF3636]Error - [#8181FF]Use this command when you have less than 100% hp !");
else
{
MessagePlayer("[#FFFF81] ---> Please wait five seconds to heal !", player);
NewTimer("heal", 5000, 1);
}
}

Code: [Select]
function heal(player, command, arguments)
{
Player.health == 100.0;
MessagePlayer( "[#FFFF81]---> You have been healed !", player);
}
72
Scripting and Server Management / client side script, dofile
« on August 9th, 2017, 04:06 PM »
I am making my own server in vcmp. I know javascript so I understand squirrel a little. Due to lack of squirrel knowledge, I am unable to perform some tasks. Plz, help me.
My questions are:
how to install client side script?(I don't know so I am unable to add registration system)

Whenever I use dofile option, the file doesn't attach and give an error that script load not executed. How to correctly use the option and where to the file to be attached?