i dont now whats rong the scrip start up bhut i kant use them
world = getWorld();
database = getDatabase();
function onEnable()
print("test!");
end
function onPlayerCommand(event)
local command = event.command;
local cmd = StringUtils:explode(command, " ");
if cmd[1] == "/setplace" then
local PlayerName = event.player:getName();
local PlaceTargetPos = event.player:getPosition();
local PlaceNewPosx = PlaceTargetPos.x;
local PlaceNewPosy = PlaceTargetPos.y;
local PlaceNewPosz = PlaceTargetPos.z;
result = database:query("SELECT PlacePos_x, PlacePos_y, PlacePos_z, count(ID) as count FROM home WHERE PlayerName = '".. PlayerName .."' ORDER BY id DESC LIMIT 1;")
while result:next() do
local count = result:getInt("count")
if count > 0 then
database:queryupdate("UPDATE `home` SET `Placepos_x` = '".. PlaceNewPosx .."', `Placepos_y` = '".. PlaceNewPosy .."', `PlaceposPos_z` = '".. PlaceNewPosz .."' WHERE `PlayerName` = '".. PlayerName .."';");
event.player:sendTextMessage("Your home point has been changed.");
else
database:queryupdate("INSERT INTO home ('PlayerName', 'PlacePos_x', 'PlacePos_y', 'PlacePos_z') VALUES ('".. PlayerName .."', '".. PlaceNewPosx .. "', '".. PlaceNewPosy .. "', '".. PlaceNewPosz .. "')");
event.player:sendTextMessage("Your new home point was created.");
end
end
result:close();
elseif cmd[1] == "/place" then
local PlayerName = event.player:getName();
result = database:query("SELECT PlacePos_x, PlacePos_y, PlacePos_z, count(ID) as count FROM home WHERE PlayerName = '".. PlayerName .."' ORDER BY id DESC LIMIT 1;")
while result:next() do
local count = result:getInt("count")
if count > 0 then
local newPosx = result:getString("PlacePos_x");
local newPosy = result:getString("PlacePos_y") + 1.0;
local newPosz = result:getString("PlacePos_z");
event.player:setPosition(newPosx, newPosy, newPosz);
event.player:sendTextMessage("You are bound to your home.");
else
event.player:sendTextMessage("Hmm, nothing found! You've probably made no sethome?!");
end
end
result:close();
elseif cmd[1] == "/homeadmin" then
if not event.player:isAdmin() then
event.player:sendTextMessage("[#FF0000][error] You are not an admin.");
return;
end
if #cmd >= 2 then
local PlayerName = cmd[2];
result = database:query("SELECT PlacePos_x, PlacePos_y, PlacePos_z, count(ID) as count FROM home WHERE PlayerName = '".. PlayerName .."' ORDER BY id DESC LIMIT 1;")
while result:next() do
local count = result:getInt("count")
if count > 0 then
local newPosx = result:getString("PlacePos_x");
local newPosy = result:getString("PlacePos_y") + 1.0;
local newPosz = result:getString("PlacePos_z");
event.player:setPosition(newPosx, newPosy, newPosz);
event.player:sendTextMessage("You are on the home by the player".. PlayerName .." keep it clean.");
else
event.player:sendTextMessage("Hmm, nothing found! player ".. PlayerName .." probably made no sethome yet?!");
end
end
result:close();
else
event.player:sendTextMessage("[#FF0000][tip] Use / home admin <name>");
end
end
end
addEvent("PlayerCommand", onPlayerCommand);