Menu

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.

Show posts Menu

Topics - umar4911

#61
I have added a custom weapon. What will be the function to play sound on fire??
#62
I have made many commands in my server. The problem I am facing is with getTok.
See this as an example
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
I was making spawn protection.
I added this onplayerspawn

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


Function
function visibility(player)
{
player.Immunity = 0;
MessagePlayer("Spawn Protection Disabled", player);
}

Error
An error has occured[trying to set in integer]
#64
I was making my gotoloc and encountered a small problem. Please fix it.
I am a little weak in making functions
onplayercommand
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
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
Oct 06, 2017, 05:32 PM
I made a spawnloc system. My friend also wanted it so I thought to post it.

add this onScriptLoad()
[spoiler]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) )" );

[/spoiler]



function onPlayerCommand(player, command, arguments)
[spoiler]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);
   }
  }
 }
 
[/spoiler]



function onPlayerSpawn(player)
[spoiler]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);
}
[/spoiler]
#66
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
Sep 22, 2017, 05: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
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

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
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
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.
[spoiler]
function onScriptLoad()
{
 locations <- ConnectSQL( "databases/locations.db");
 print("Locations loaded.");
}





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);


}
}


}

 
 
[/spoiler]


SetHP
[spoiler]  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);
}
}
}
 

}

[/spoiler]

Can anybody give me the code of Set time and set weather. The code of set timer in wiki is wrong!!
#71
Can anybody give me the code of set time and weather? The time one in wiki is wrong


Please fix this code too.
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);
}
}

function heal(player, command, arguments)
{
Player.health == 100.0;
MessagePlayer( "[#FFFF81]---> You have been healed !", player);
}
#72
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?