Difference between revisions of "UScript for Unturned Code Samples"

From Free Knowledge Base- The DUCK Project: information for everyone
Jump to: navigation, search
(Created page with "== SQL Related == === populate an arrow with records from SQL table === vRecords = database.allRows("SELECT * FROM uconomy ORDER BY balance DESC LIMIT " + n); === prevent er...")
 
m
 
(2 intermediate revisions by one user not shown)
Line 1: Line 1:
 +
== Messages ==
 +
=== broadcast a message to allow players on server ===
 +
broadcast("Door Alarm triggered! Door InstanceID: {0} | Name of inturder: {1}".format(doorid, player.name), "red");
 +
 +
=== send an on screen message to a single player ===
 +
player.message("Door InstanceID: " + doorid, "red");
 +
 +
=== echo a message to console ===
 +
echo ("message");
 +
 
== SQL Related ==
 
== SQL Related ==
 
=== populate an arrow with records from SQL table ===
 
=== populate an arrow with records from SQL table ===
Line 5: Line 15:
 
=== prevent error from comparisons when array is empty because SQL record is missing or null ===
 
=== prevent error from comparisons when array is empty because SQL record is missing or null ===
 
  if (vPlayerName.count == 0) {
 
  if (vPlayerName.count == 0) {
 +
 +
== Event Examples ==
 +
event  onZombieKilled(player){
 +
    PlayerData = AllPlayerInfo[i];
 +
    broadcast(player.name + " killed a zombie.");
 +
}
 +
 +
event onPlayerEquipped(player, item){
 +
 +
== Other Examples ==
 +
=== Players in server===
 +
  foreach(player in server.players) {
 +
  }

Latest revision as of 15:48, 9 January 2025

Messages

broadcast a message to allow players on server

broadcast("Door Alarm triggered! Door InstanceID: {0} | Name of inturder: {1}".format(doorid, player.name), "red");

send an on screen message to a single player

player.message("Door InstanceID: " + doorid, "red");

echo a message to console

echo ("message");

SQL Related

populate an arrow with records from SQL table

vRecords = database.allRows("SELECT * FROM uconomy ORDER BY balance DESC LIMIT " + n);

prevent error from comparisons when array is empty because SQL record is missing or null

if (vPlayerName.count == 0) {

Event Examples

event  onZombieKilled(player){
    PlayerData = AllPlayerInfo[i];
    broadcast(player.name + " killed a zombie.");
}
event onPlayerEquipped(player, item){

Other Examples

Players in server

 foreach(player in server.players) {
 }