Server update: 0.3a R8
#21

Oh my god. Thanks sa-mp dev team, nice update. And it's not even 0.3b!
Reply
#22

OMG!!! This is great.
Reply
#23

Nicely done, especially like the pVar system.

Will put it into action tomorrow.
Reply
#24

Quote:
Originally Posted by Kye
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;
}
Dude.., that's just an awesome update and feature! love you guys!
Reply
#25

Quote:
Originally Posted by CJ101
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
Ditto, very very nice.
Reply
#26

Quote:
Originally Posted by Norn [BINMAN
]
Nicely done, especially like the pVar system.

Will put it into action tomorrow.
Same, same. Could anyone provide me with an example of what GetPlayerWeaponState() returns? Like 1 if aiming? or whatever?
Reply
#27

Quote:
Originally Posted by FreddoX [BINMAN
]
Same, same. Could anyone provide me with an example of what GetPlayerWeaponState() returns? Like 1 if aiming? or whatever?
Take a look at a_players.inc
Reply
#28

Quote:
Originally Posted by CrαcK
Quote:
Originally Posted by FreddoX [BINMAN
]
Same, same. Could anyone provide me with an example of what GetPlayerWeaponState() returns? Like 1 if aiming? or whatever?
Take a look at a_players.inc
Includes only show the parameters, NOT what is returned.
Reply
#29

This is just awesome.
Reply
#30

Quote:
Originally Posted by FreddoX [BINMAN
]
Includes only show the parameters, NOT what is returned.
Before saying something like this, check precisely what I said to
Reply
#31

awesome kye
Reply
#32

Code:
OnVehicleDamageStatusUpdate(vehicleid, playerid);
Does this include vehicle damage in general (% wise), or specifically visual damage only?
Reply
#33

UpdateVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
I smell working light script
Reply
#34

Good camera and vehicles stuff. Thanks.


Quote:

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.

Good thing for flags is char operator. Creating:
Code:
// creating a packed string or array with 125 cells and 500 1-byte elements
new PlayerInfo[MAX_PLAYERS char];
and usage example
Code:
PlayerInfo{playerid} = 0;
PlayerInfo{456} = 100;
PlayerInfo[0] = 65530; // now PlayerInfo{0} is 255, PlayerInfo{1} is 250
i think PVar is not necessary
Reply
#35

Don't forget it's also an easier way to have cross script variables.
Reply
#36

-_- requesting PVar tutorial

Other then that, great job.
Reply
#37

can you make this in the samp.com download page
Reply
#38

Quote:
Originally Posted by Brian_Furios
can you make this in the samp.com download page
They'll put it there, don't rush.

http://files.sa-mp.com/
Reply
#39

Quote:
Originally Posted by Don Correlli
Quote:
Originally Posted by Brian_Furios
can you make this in the samp.com download page
They'll put it there, don't rush.

http://files.sa-mp.com/
ok ok
Reply
#40

Just arrived -> just needed!
Thanks for the damage func. to fix my vehicle's healthcheck

Good job.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)