Client
events.nut
fps.nut
guistest.nut
scoreboard.nut
Server
ebdm.nut
meta.xml
İndir TIKLA
events.nut
Kod:
// events.nut By AaronLad
addEventHandler( "serverEvent",
function( script, str )
{
triggerServerEvent( "eventConfirm" );
}
);
fps.nut
Kod:
// fps.nut By AaronLad
addEventHandler( "onClientFrameRender",
function( post )
{
if( post )
dxDrawText( "FPS: " + getFPS(), 2.0, 2.0, 0xFFFFFFFF, true, "tahoma-bold" );
}
)
guistest.nut
Kod:
local button = null;
addCommandHandler("createGUI",function(pid)
{
if (!button) {
button = guiCreateElement(ELEMENT_TYPE_BUTTON, "Hello World", 500, 500, 100, 35);
sendMessage("ELement created");
}
});
addCommandHandler("destroyGUI", function(pid)
{
if (button) {
guiDestroyElement(button);
button = null;
sendMessage("Element destroyed");
}
});
// eof
scoreboard.nut
Kod:
// scoreboard.nut By AaronLad
// Variables
local drawScoreboard = false;
local screenSize = getScreenSize( );
// Scoreboard math stuff
local fPadding = 5.0, fTopToTitles = 25.0;
local fWidth = 600.0, fHeight = ((fPadding * 2) + (fTopToTitles * 3));
local fOffsetID = 50.0, fOffsetName = 450.0;
local fPaddingPlayer = 20.0;
local fX = 0.0, fY = 0.0, fOffsetX = 0.0, fOffsetY = 0.0;
function tabDown()
{
drawScoreboard = true;
showChat( false );
// Add padding to the height for each connected player
for( local i = 0; i < MAX_PLAYERS; i++ )
{
if( isPlayerConnected(i) )
fHeight += fPaddingPlayer;
}
}
bindKey( "tab", "down", tabDown );
function tabUp()
{
drawScoreboard = false;
showChat( true );
// Reset the height
fHeight = ((fPadding * 2) + (fTopToTitles * 3));
}
bindKey( "tab", "up", tabUp );
function playerConnect( playerid, nickname )
{
// Are we rendering the scoreboard?
if( drawScoreboard )
fHeight += fPaddingPlayer;
}
addEventHandler( "onClientPlayerConnect", playerConnect );
function playerDisconnect( playerid )
{
// Are we rendering the scoreboard?
if( drawScoreboard )
{
// Remove the height from this player
fHeight = fHeight - fPaddingPlayer;
}
}
addEventHandler( "onClientPlayerDisconnect", playerDisconnect );
function deviceReset()
{
// Get the new screen size
screenSize = getScreenSize();
}
addEventHandler( "onClientDeviceReset", deviceReset );
function frameRender( post_gui )
{
if( post_gui && drawScoreboard )
{
fX = ((screenSize[0] / 2) - (fWidth / 2));
fY = ((screenSize[1] / 2) - (fHeight / 2));
fOffsetX = (fX + fPadding);
fOffsetY = (fY + fPadding);
dxDrawRectangle( fX, fY, fWidth, fHeight, fromRGB( 0, 0, 0, 128 ) );
fOffsetX += 25.0;
fOffsetY += 25.0;
dxDrawText( "ID", fOffsetX, fOffsetY, 0xFFFFFFFF, true, "tahoma-bold" );
fOffsetX += fOffsetID;
dxDrawText( "Nickname", fOffsetX, fOffsetY, 0xFFFFFFFF, true, "tahoma-bold" );
fOffsetX += fOffsetName;
dxDrawText( "Ping", fOffsetX, fOffsetY, 0xFFFFFFFF, true, "tahoma-bold" );
// Draw the localplayer
fOffsetX = (fX + fPadding + 25.0);
fOffsetY += 20.0;
dxDrawText( getLocalPlayer().tostring(), fOffsetX, fOffsetY, getPlayerColour(getLocalPlayer()), true, "tahoma-bold" );
fOffsetX += fOffsetID;
dxDrawText( getPlayerName(getLocalPlayer()), fOffsetX, fOffsetY, getPlayerColour(getLocalPlayer()), true, "tahoma-bold" );
fOffsetX += fOffsetName;
dxDrawText( getPlayerPing(getLocalPlayer()).tostring(), fOffsetX, fOffsetY, getPlayerColour(getLocalPlayer()), true, "tahoma-bold" );
// Draw remote players
for( local i = 0; i < MAX_PLAYERS; i++ )
{
if( i != getLocalPlayer() )
{
if( isPlayerConnected(i) )
{
fOffsetX = (fX + fPadding + 25.0);
fOffsetY += fPaddingPlayer;
dxDrawText( i.tostring(), fOffsetX, fOffsetY, getPlayerColour(i), true, "tahoma-bold" );
fOffsetX += fOffsetID;
dxDrawText( getPlayerName(i), fOffsetX, fOffsetY, getPlayerColour(i), true, "tahoma-bold" );
fOffsetX += fOffsetName;
dxDrawText( getPlayerPing(i).tostring(), fOffsetX, fOffsetY, getPlayerColour(i), true, "tahoma-bold" );
}
}
}
}
}
addEventHandler( "onClientFrameRender", frameRender );
Server
ebdm.nut
Kod:
/**
* Setup gammeode defaults
* And create startup resources (spawn cars/etc.)
*/
local script = "Empire Bay Death Match";
function scriptInit()
{
log( script + " Loaded!" );
setGameModeText( "EB-DM" );
setMapName( "Empire Bay" );
// Create cars surrounding the spawn bar.
createVehicle(1, -1567.36, -193.678, -20.1856, -92.0449, 0.223556, 3.04026);
createVehicle(8, -1546.6, -156.406, -19.2969, -0.241408, 2.89541, -2.29698);
createVehicle(9, -1537.77, -168.93, -19.4142, 0.0217354, 0.396637, -2.80105);
createVehicle(10, -1546.66, -181.15, -20.1519, 179.887, 3.31208, -0.653084);
}
addEventHandler( "onScriptInit", scriptInit );
/**
* Add hanlding of player events
* (player connections/disconnections/spawning)
*/
function playerConnect( playerid, name, ip, serial )
{
sendPlayerMessageToAll( "~ " + getPlayerName( playerid ) + " has joined the server.", 255, 204, 0 );
}
addEventHandler( "onPlayerConnect", playerConnect );
function playerDisconnect( playerid, reason )
{
sendPlayerMessageToAll( "~ " + getPlayerName( playerid ) + " has left the server. (" + reason + ")", 255, 204, 0 );
}
addEventHandler( "onPlayerDisconnect", playerDisconnect );
function playerSpawn( playerid )
{
setPlayerPosition( playerid, -1551.560181, -169.915466, -19.672523 );
setPlayerHealth( playerid, 720.0 );
sendPlayerMessage(playerid, "Welcome to Mafia2-Online Official Test Server!", 150, 150, 230);
sendPlayerMessage(playerid, "You can test there some of the features :p", 150, 150, 230);
sendPlayerMessage(playerid, "For help use command /help", 204, 255, 0);
triggerClientEvent( playerid, "serverEvent", script, "a test string" );
}
addEventHandler( "onPlayerSpawn", playerSpawn );
/**
* Demo of server-client-server event binding
* and triggering
*/
addEventHandler( "eventConfirm",
function( playerid )
{
givePlayerWeapon( playerid, 10, 2500 );
givePlayerWeapon( playerid, 11, 2500 );
givePlayerWeapon( playerid, 12, 2500 );
}
);
/**
* Hanling of various player events
*/
function playerDeath( playerid, killerid )
{
if( killerid != INVALID_ENTITY_ID )
sendPlayerMessageToAll( "~ " + getPlayerName( playerid ) + " has been killed by " + getPlayerName( killerid ) + ".", 255, 204, 0 );
else
sendPlayerMessageToAll( "~ " + getPlayerName( playerid ) + " has died.", 255, 204, 0 );
}
addEventHandler( "onPlayerDeath", playerDeath );
/**
* Adding command handlers
*/
addCommandHandler("help", function(playerid) {
local commands = [
{ name = "/spawn", desc = "Teleport to spawn" },
{ name = "/weapons", desc = "Give yourself some damn guns!" },
{ name = "/heal", desc = "Restore your precious health points :p"},
{ name = "/die", desc = "If you dont wanna live there anymore" },
{ name = "/vehicle <id>", desc = "Spawn vehicle, example /vehicle 45" },
{ name = "/tune", desc = "Tune up your vehicle!" },
{ name = "/fix", desc = "Fix up your super vehicle" },
{ name = "/destroyVehicle", desc = "Remove car you are in" },
{ name = "/skin <id>", desc = "Change your skin :O. Example: /skin 63" }
];
sendPlayerMessage(playerid, "");
sendPlayerMessage(playerid, "==================================", 200, 100, 100);
sendPlayerMessage(playerid, "Here is list of available commands:", 200, 200, 0);
foreach (idx, cmd in commands) {
local text = " * Command: " + cmd.name + " - " + cmd.desc;
if ((idx % 2) == 0) {
sendPlayerMessage(playerid, text, 200, 230, 255);
} else {
sendPlayerMessage(playerid, text);
}
}
});
addCommandHandler("tptome", function(playerid, pttpid) {
if (!pttpid) {
sendPlayerMessage(playerid, "/tptome <pttpid>");
return;
}
local playerToTeleport = pttpid.tointeger();
if (!isPlayerConnected(playerToTeleport)) {
sendPlayerMessage(playerid, "Player with given id is not connected.");
return;
}
local myPos = getPlayerPosition(playerid);
setPlayerPosition(playerToTeleport, myPos[0], myPos[1], myPos[2]);
});
addCommandHandler("spawn", function(playerid) {
setPlayerPosition( playerid, -1551.560181, -169.915466, -19.672523 );
setPlayerHealth( playerid, 720.0 );
});
addCommandHandler("weapons", function(playerid) {
givePlayerWeapon( playerid, 10, 2500 );
givePlayerWeapon( playerid, 11, 2500 );
givePlayerWeapon( playerid, 12, 2500 );
});
addCommandHandler("vehicle", function( playerid, id ) {
local pos = getPlayerPosition( playerid );
local rot = getPlayerRotation( playerid );
createVehicle( id.tointeger(), pos[0] + 2.0, pos[1], pos[2] + 1.0, 0.0, rot[1], 0.0 );
});
addCommandHandler("tune", function( playerid ) {
if( isPlayerInVehicle( playerid ) )
{
local vehicleid = getPlayerVehicle( playerid );
setVehicleTuningTable( vehicleid, 3 );
setVehicleWheelTexture( vehicleid, 0, 11 );
setVehicleWheelTexture( vehicleid, 1, 11 );
}
});
addCommandHandler( "destroyVehicle",
function( playerid )
{
if( isPlayerInVehicle( playerid ) )
{
local vehicleid = getPlayerVehicle( playerid );
destroyVehicle( vehicleid );
}
}
);
addCommandHandler( "colTest",
function( playerid )
{
if( isPlayerInVehicle( playerid ) )
{
local vehicleid = getPlayerVehicle( playerid );
repairVehicle( vehicleid );
}
}
);
addCommandHandler( "fix",
function( playerid )
{
if( isPlayerInVehicle( playerid ) )
{
local vehicleid = getPlayerVehicle( playerid );
repairVehicle( vehicleid );
}
}
);
addCommandHandler( "heal",
function( playerid )
{
setPlayerHealth( playerid, 720.0 );
}
);
addCommandHandler( "skin",
function( playerid, id )
{
setPlayerModel( playerid, id.tointeger() );
}
);
addCommandHandler( "die",
function( playerid )
{
setPlayerHealth( playerid, 0.0 );
}
);
meta.xml
Kod:
<meta>
<script type="server">ebdm.nut</script>
<script type="client">fps.nut</script>
<script type="client">scoreboard.nut</script>
<script type="client">events.nut</script>
<script type="client">guitest.nut</script>
</meta>
İndir TIKLA