Server update: 0.3a R8
#1

SA-MP 0.3a R8 Server

22/06/2010

- 0.3a R8 server fixes a denial of service attack where an external program interfacing with SA-MP's network layer could send a misaligned payload to RPCs.

Windows: http://files.sa-mp.com/samp03asvr_R8_win32.zip
Linux: http://files.sa-mp.com/samp03asvr_R8.tar.gz

SA-MP 0.3a R7 Server

28/03/2010

Windows: http://files.sa-mp.com/samp03asvr_R7_win32.zip
Linux: http://files.sa-mp.com/samp03asvr_R7.tar.gz

Changes from R6 server:

- There was a problem with the PVar list after DeletePVar() had been used (thanks to Toribio for pointing this out).
- PVar names use uppercase internally which speeds up the lookups. When you enumerate PVars the name will always be returned in uppercase. You can still use any case for getting/setting.

SA-MP 0.3a R6 Server

27/03/2010

Changes from R5 server:

- PVar names use exact names instead of partial matching, they're case-insensitive still ("id" is the same as "ID").
- PVars are now reset during a game mode restart.
- Hopefully fixed crash on Windows server related to a compiler problem.
- Vehicle mods sent by players have additional sanity checks (thanks to Tenshi for pointing out a problem).

SA-MP 0.3a R5 Server

23/03/2010

A new server update is being made available immediately due to a "denial of service" attack on several popular SA-MP servers.

Note: this is not 0.3b. This is an optional server-only update. It does not fix all existing bugs, as many fixes will have to wait until the next mandatory client/server update.

0.3a R5 fixes a "denial of service" vulnerability where a player sending invalid data, generated by an external program, may cause the server to generate a debug assertion, which causes the server to close.

The R5 server also contains some new scripting features that missed the initial 0.3a server releases.

Camera information:

With the camera information you can tell where a player is looking. Please note the player's camera info is only updated while they are onfoot, spectating or driving a vehicle which has a special turret like the firetruck/swatvan etc.

pawn Code:
native GetPlayerWeaponState(playerid);
native GetPlayerCameraPos(playerid, &Float:x, &Float:y, &Float:z);
native GetPlayerCameraFrontVector(playerid, &Float:x, &Float:y, &Float:z);
native GetPlayerCameraUpVector(playerid, &Float:x, &Float:y, &Float:z);
Per-player variable system: (PVars).

Originally SA-MP was only designed for 100 maximum players. This meant defining arrays in pawn of MAX_PLAYERS size such as: PlayerInfo[MAX_PLAYERS] was generally okay. Now that MAX_PLAYERS is defined as 500, script writers are finding themselves creating arrays with 500 elements just to store a single flag. This can turn out to be very wasteful in terms of memory use. These variables also need to be manually reset when the player using them leaves the server.

Advantages of using PVars over arrays of MAX_PLAYERS:
1) PVars can be shared/accessed across gamemode scripts and filterscripts, making it easier to modularise your code.
2) PVars are automatically deleted when a player leaves the server, meaning you don't have to manually reset variables for the next player who joins.
3) No real need for complex enums/player info structures.
4) Saves memory by not allocating pawn array elements for playerids which will probably never be used.
5) You can easily enumerate and print/store the PVar list. This makes both debugging and player info storage easier.
6) Even if a PVar hasn't been created, it still will return a default value of 0.
7) PVars can hold very large strings using dynamically allocated memory.

pawn Code:
// Per-player variable system (PVars)
native SetPVarInt(playerid, varname[], int_value);
native GetPVarInt(playerid, varname[]);
native SetPVarString(playerid, varname[], string_value[]);
native GetPVarString(playerid, varname[], string_return[], len);
native SetPVarFloat(playerid, varname[], Float:float_value);
native Float:GetPVarFloat(playerid, varname[]);
native DeletePVar(playerid, varname[]);

// PVar enumeration
#define PLAYER_VARTYPE_NONE         0
#define PLAYER_VARTYPE_INT          1
#define PLAYER_VARTYPE_STRING       2
#define PLAYER_VARTYPE_FLOAT        3

native GetPVarsUpperIndex(playerid);
native GetPVarNameAtIndex(playerid, index, ret_varname[], ret_len);
native GetPVarType(playerid, varname[]);
Addition to player markers:

If the player markers mode is PLAYER_MARKERS_MODE_GLOBAL, you can limit the radius which the player markers are drawn for each player. This may be important on some servers since there are limits to how many total markers you can have in GTA SA.

pawn Code:
native LimitPlayerMarkerRadius(Float:marker_radius);
Additional vehicle damage functions:

Vehicle damage callback is called when a player updates the damage information on their vehicle.
New functions allow you to get and set the vehicle damage information.

pawn Code:
forward OnVehicleDamageStatusUpdate(vehicleid, playerid);
native GetVehicleDamageStatus(vehicleid, &panels, &doors, &lights, &tires);
native UpdateVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
Other:

Fix for pawn's fseek() function.
Reply
#2

Some handy utils functions for dealing with lists of PVars:

Code:
//-------------------------------------------
// Sends a list of all PVars to the player as
// client messages.

SendPVarListToPlayer(playerid)
{
  new ubound = GetPVarsUpperIndex(playerid);
	new x=0;
	new name[40+1];
	new line[128+1];
	
  SendClientMessage(playerid,0xF000F0F0, "---Player Vars List---");
	while(x != ubound) {
		if(GetPVarNameAtIndex(playerid,x,name,40)) {
			if(Util_GetPVarEntryAsString(playerid,name,line,128)) {
         SendClientMessage(playerid,0xFFFFFFFF,line);
			}
		}
		x++;
	}
}

//-------------------------------------------
// return PVar entry as 'name'='value' string

stock Util_GetPVarEntryAsString(playerid, name[], ret[], len)
{
	new Float:fValue;
	new iValue;
	new szStrValue[1024+1]; // this might require greater size if you store large strings in PVars
	new type;
  ret[0] = EOS;
  
 	type = GetPVarType(playerid, name);
	if(type != PLAYER_VARTYPE_NONE) {
		switch(type)
		{
			case PLAYER_VARTYPE_STRING:
			{
				GetPVarString(playerid,name,szStrValue,1024);
				format(ret,len,"%s=%s",name,szStrValue);
			}
			case PLAYER_VARTYPE_INT:
			{
				iValue = GetPVarInt(playerid,name);
				format(ret,len,"%s=%d",name,iValue);
			}
			case PLAYER_VARTYPE_FLOAT:
			{
			  fValue = GetPVarFloat(playerid,name);
				format(ret,len,"%s=%f",name,fValue);
			}
		}
		return 1;
	}
	return 0;
}

//-------------------------------------------
// Fills the provided string with all the player's PVars
// seperated by the specified 'delimiter'

stock Util_CreatePVarList(playerid, retstr[], len, delimiter[])
{
	if(!IsPlayerConnected(playerid)) return 0;
	
	new x=0;
	new remaining_string=len;
	new line[2048+1];
	new name[40+1];
	retstr[0] = EOS;

	new ubound = GetPVarsUpperIndex(playerid);
	
	while(x != ubound) {
		if(GetPVarNameAtIndex(playerid,x,name,40)) {
			if(Util_GetPVarEntryAsString(playerid,name,line,2048)) {
				// if there is enough space, concat this line to the return string
				if(remaining_string > (strlen(line) + strlen(delimiter))) {
			  	strcat(retstr,line);
			  	strcat(retstr,delimiter);
					remaining_string -= (strlen(line) + strlen(delimiter));
				}
			}
		}
		x++;
	}
	
	return 1;
}

//-------------------------------------------
Reply
#3

If you are a serverFFS customer, your server has already been updated to this version to fix the exploit and provide the new scripting features.
To apply this update, simply restart your server through the control panel.

Have fun with all the new features that R5 offers, it'll keep the scripters busy again
Reply
#4

I really like the Camera updates, I'll update right away.
Reply
#5

Well done! Thanks for the new features.
Reply
#6

cool
Reply
#7

Awesome, special thank to everyone for the hard work of finding the bugs and fixing them. My server is now running SA:MP RC5, also thanks to ServerFFS for the support to update my server. Great job team!
Reply
#8

Good job!
Reply
#9

Quote:
Originally Posted by Kye
pawn Code:
forward OnVehicleDamageStatusUpdate(vehicleid, playerid);
native GetVehicleDamageStatus(vehicleid, &panels, &doors, &lights, &tires);
native UpdateVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
I like these

good job kye, keep up the good work man
Reply
#10

Epic, good work!
Reply
#11

I smell headshots and other limb-specific weapon damage!
Reply
#12

Dealing with individual vehicle damage elements can be a little bit tricky because they're compressed in to bits to save space.

JernejL (RedShirt) has provided an example of dealing with individual damage elements and also provided some reusable functions:

pawn Code:
const object_undamaged = 0;
const door_swinging = 1;
const door_damaged = 2;
const door_damaged_swinging = 3;
const door_fell_off = 4;
   
const windshield_crackedA = 1;
const windshield_crackedB = 2;
const windshielddestroyed = 3;

encode_lights(light1, light2, light3, light4) {
   
    return light1 | (light2 << 1) | (light3 << 2) | (light4 << 3);
   
}

encode_tires(tire1, tire2, tire3, tire4) {
   
    return tire1 | (tire2 << 1) | (tire3 << 2) | (tire4 << 3);
   
}

encode_tires_bike(rear, front) {
   
    return rear | (front << 1);
   
}

#pragma unused encode_tires_bike

encode_doors(bonnet, boot, driver_door, passenger_door, behind_driver_door, behind_passenger_door) {
    #pragma unused behind_driver_door
    #pragma unused behind_passenger_door
       
    // will be modified once again, when rear doors are synced.
    return bonnet | (boot << 8) | (driver_door << 16) | (passenger_door << 24);
   
}

encode_panels(flp, frp, rlp, rrp, windshield, front_bumper, rear_bumper) {
   
    return flp | (frp << 4) | (rlp << 8) | (rrp << 12) | (windshield << 16) | (front_bumper << 20) | (rear_bumper << 24);
   
}

breakcar(PlayerID) {
   
    if (IsPlayerInAnyVehicle(PlayerID)) {
       
        new panels, doors, lights, tires;
       
        GetVehicleDamageStatus(GetPlayerVehicleID(PlayerID), panels, doors, lights, tires);
        panels = encode_panels(1, 1, 1, 1, 3, 3, 3); // damage windshield & make bumpers swing
        doors = encode_doors(4, 4, 4, 4, 0, 0); // make them all fall off
        lights = encode_lights(1, 1, 1, 1); // damage all lights
        tires = encode_tires(1, 1, 1, 1); // damage all tires
       
        UpdateVehicleDamageStatus(GetPlayerVehicleID(PlayerID), panels, doors, lights, tires);
       
    }
   
    return true;
}

OnVehicleDamageStatusUpdate(vehicleid, playerid) {
    #pragma unused playerid
   
    new panels, doors, lights, tires;
    GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
   
    new driver_door, passenger_door/*, behind_driver_door, behind_passenger_door*/ = 0;
   
    /*
    door & boot & bonnet status:
    0: undamaged
    1: swinging
    2: damaged
    3: damaged & swinging
    4: fell off
    */

   
    driver_door = doors >> 16 & 0x7;
    passenger_door = doors >> 24 & 0x7;
   
    // other 2 doors are not yet synced.
   
    new bonnet, boot = 0;
   
    bonnet = doors & 0x7;
    boot = doors >> 8 & 0x7; // boot will not swing unless on specific car (like a bobcat)
   
    new flp, frp, rlp, rrp, windshield, front_bumper, rear_bumper;
   
    /*
    panels are unused on cars, they are used on planes tho.
    */

   
    flp = panels >> 0 & 0xF;
    frp = panels >> 4 & 0xF;
    rlp = panels >> 8 & 0xF;
    rrp = panels >> 12 & 0xF;
   
    /*
    windshield:
    0 undagamed
    1,2 cracked
    3: destroyed
    */

   
    windshield = panels >> 16 & 0xF;
   
    /*
    bonnet & boot:
    0 undamaged
    1 open swinging (hood only)
    2 damaged
    3 damaged swinging
    4 fallen off
    */

   
    front_bumper = panels >> 20 & 0xF;
    rear_bumper = panels >> 24 & 0xF;
   
    // for tires & lights: 1 damaged, 0 = ordinary
    new tyre1, tyre2, tyre3, tyre4;
   
    tyre1 = tires >> 0 & 0x1; // rear right (bike rear)
    tyre2 = tires >> 1 & 0x1; // front right (bike front)
    tyre3 = tires >> 2 & 0x1; // rear left
    tyre4 = tires >> 3 & 0x1; // front left
   
    new light1, light2, light3, light4;
   
    light1 = lights >> 0 & 0x1; // front left
    light2 = lights >> 1 & 0x1; // cant get to break rear light
    light3 = lights >> 2 & 0x1; // front right
    light4 = lights >> 3 & 0x1; // cant get to break rear light
   
    // bike lights never break!
   
    new string[128];
    format(string,sizeof(string),"Doors: Driver: %d, Passenger: %d", driver_door, passenger_door);
    SendClientMessageToAll(COLOR_RED, string);
   
    format(string,sizeof(string),"Swinging: bonnet: %d, boot: %d", bonnet, boot);
    SendClientMessageToAll(COLOR_RED, string);
   
    format(string,sizeof(string),"panels: flp: %d, frp: %d, rlp: %d, rrp: %d, windshield: %d, front bumper: %d, rear bumper: %d", flp, frp, rlp, rrp, windshield, front_bumper, rear_bumper);
    SendClientMessageToAll(COLOR_RED, string);
   
    format(string,sizeof(string),"tires: %d %d %d %d", tyre1, tyre2, tyre3, tyre4);
    SendClientMessageToAll(COLOR_RED, string);
   
    format(string,sizeof(string),"lights: %d %d %d %d", light1, light2, light3, light4);
    SendClientMessageToAll(COLOR_RED, string);
   
    return 1;
}
Reply
#13

Thanks for the release, Kye, I hope this stops some of the ddos attacks ive had alot lately.
Reply
#14

Quote:
Originally Posted by Mr187
Thanks for the release, Kye, I hope this stops some of the ddos attacks ive had alot lately.
DDoS cannot be stopped at SA-MP level, you need a high uplink (1 gbit) with a hardware firewall (Cisco Guard, RioRey, etc.)
Software firewall will also help as long as the amount of traffic doesn't overflow the uplink.
Further more, this isn't a specific SA-MP problem, DDoS is unrelated to the software running.
Reply
#15

Thankyou Kye... we appreciate your work!

Reply
#16

oh its very great, big thanks
Reply
#17

Quote:
Originally Posted by Tannz0rz
I smell headshots and other limb-specific weapon damage!
They can make it now?
Reply
#18

thank you kye.
Reply
#19

Quote:
Originally Posted by Woet
Quote:
Originally Posted by Mr187
Thanks for the release, Kye, I hope this stops some of the ddos attacks ive had alot lately.
DDoS cannot be stopped at SA-MP level, you need a high uplink (1 gbit) with a hardware firewall (Cisco Guard, RioRey, etc.)
Software firewall will also help as long as the amount of traffic doesn't overflow the uplink.
Further more, this isn't a specific SA-MP problem, DDoS is unrelated to the software running.
The thing i meaned was, My server would feel like it was being ddosed the past few weeks but didn't seem to be anything big, So hopefully this fixes the problem a bit.

And please, I know it isn't a SA-MP Problem, But the fact he fixed a problem regrading a overflow of usless connections fix, Is always a good fix and could always help.
Reply
#20

Looks good, nice improvements. Thanks Kye and the Samp Dev's!!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)