sfcnr/gamemodes/irresistible/cnr/features/perks.pwn

210 lines
7.3 KiB
Plaintext
Raw Normal View History

/*
* Irresistible Gaming (c) 2018
* Developed by Lorenc
* Module: cnr\features\perks.pwn
* Purpose: perks system
*/
/* ** Includes ** */
#include < YSI\y_hooks >
2018-10-10 01:00:29 +00:00
/* ** Variables ** */
static stock
bool: p_OffRadar [ MAX_PLAYERS char ],
p_OffRadarTimestamp [ MAX_PLAYERS ],
p_OffRadarVisible [ MAX_PLAYERS ]
;
/* ** Hooks ** */
2018-10-10 01:00:29 +00:00
hook OnPlayerDisconnect( playerid, reason )
{
p_OffRadar{ playerid } = false;
return 1;
}
hook OnPlayerSpawn( playerid )
{
p_OffRadar{ playerid } = false;
return 1;
}
hook OnPlayerUpdateEx( playerid )
{
if ( IsPlayerHiddenFromRadar( playerid ) )
{
new
current_time = GetServerTime( );
// Expire stealth mode after 30 seconds
if ( p_OffRadarTimestamp[ playerid ] != 0 && current_time > p_OffRadarTimestamp[ playerid ] ) {
p_OffRadar{ playerid } = false;
SetPlayerColorToTeam( playerid );
SendServerMessage( playerid, "Your hide from radar perk has now expired." );
}
// Stealth mode after getting shot
else if ( p_OffRadarVisible[ playerid ] != 0 && current_time > p_OffRadarVisible[ playerid ] ) {
SetPlayerColorToTeam( playerid ), p_OffRadarVisible[ playerid ] = 0;
}
}
return 1;
}
hook OnPlayerWeaponShot( playerid, weaponid, hittype, hitid, Float: fX, Float: fY, Float: fZ )
{
if ( hittype == BULLET_HIT_TYPE_PLAYER ) {
// Exposing stealth mode player
if ( IsPlayerHiddenFromRadar( playerid ) ) {
SetPlayerColor( playerid, setAlpha( GetPlayerColor( playerid ), 0xFF ) ), p_OffRadarVisible[ playerid ] = g_iTime + 2;
}
}
return 1;
}
hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
{
if ( dialogid == DIALOG_PERKS && response )
{
switch( listitem )
{
case 0: ShowPlayerDialog( playerid, DIALOG_PERKS_P, DIALOG_STYLE_TABLIST_HEADERS, "{FFFFFF}Deathmatch Perks", ""COL_WHITE"Item Name\t"COL_WHITE"Cost (XP)\nHide From Radar\t"COL_GREEN"250 XP\nUnlimited Ammunition\t"COL_GREEN"100 XP", "Select", "Back" );
case 1: ShowPlayerDialog( playerid, DIALOG_PERKS_V, DIALOG_STYLE_TABLIST_HEADERS, "{FFFFFF}Robbery Perks", ""COL_WHITE"Item Name\t"COL_WHITE"Cost (XP)\nFix & Flip vehicle\t"COL_GREEN"180 XP\nRepair Vehicle\t"COL_GREEN"120 XP\nAdd NOS\t"COL_GREEN"80 XP\nFlip vehicle\t"COL_GREEN"50 XP", "Select", "Back" );
}
}
else if ( dialogid == DIALOG_PERKS_P )
{
if ( !response )
return ShowPlayerDialog( playerid, DIALOG_PERKS, DIALOG_STYLE_LIST, "{FFFFFF}Game Perks", "Deathmatch Perks\nRobbery Perks", "Select", "Cancel" );
new
Float: total_dm_xp = GetPlayerExperience( playerid, E_DEATHMATCH );
switch( listitem )
{
case 0:
2018-10-10 01:00:29 +00:00
{
if ( total_dm_xp < 250 ) {
return SendError( playerid, "You need at least 250 Deathmatch XP for this item." );
2018-10-10 01:00:29 +00:00
}
if ( GetPlayerClass( playerid ) != CLASS_CIVILIAN ) {
return SendError( playerid, "You need to be a civilian to use this perk." );
}
p_OffRadar{ playerid } = true;
2018-10-15 05:15:33 +00:00
p_OffRadarTimestamp[ playerid ] = GetServerTime( ) + 180;
2018-10-10 01:00:29 +00:00
GivePlayerExperience( playerid, E_DEATHMATCH, -250, .with_dilation = false );
2018-10-10 01:00:29 +00:00
SendServerMessage( playerid, "You have hidden yourself from the radar (3 minutes) for 250 Deathmatch XP." );
2018-10-15 05:15:33 +00:00
ShowPlayerHelpDialog( playerid, 3000, "~g~~h~Hide from radar ~w~will be deactivate in 3 minutes." );
2018-10-10 01:00:29 +00:00
SetPlayerColor( playerid, setAlpha( GetPlayerColor( playerid ), 0x00 ) );
Beep( playerid );
}
case 1:
{
if ( total_dm_xp < 100 ) {
return SendError( playerid, "You need at least 100 Deathmatch XP for this item." );
}
for ( new i = 0; i < MAX_WEAPONS; i++ )
{
if ( IsWeaponInAnySlot( playerid, i ) && i != 0 && !( 16 <= i <= 18 ) && i != 35 && i != 47 && i != WEAPON_BOMB )
{
GivePlayerWeapon( playerid, i, 15000 );
}
}
GivePlayerExperience( playerid, E_DEATHMATCH, -100, .with_dilation = false );
SendServerMessage( playerid, "You have bought unlimited ammunition for 100 Deathmatch XP." );
SetPlayerArmedWeapon( playerid, 0 );
Beep( playerid );
}
}
}
else if ( dialogid == DIALOG_PERKS_V )
{
if ( !response )
return ShowPlayerDialog( playerid, DIALOG_PERKS, DIALOG_STYLE_LIST, "{FFFFFF}Game Perks", "Deathmatch Perks\nRobbery Perks", "Select", "Cancel" );
if ( !IsPlayerInAnyVehicle( playerid ) || GetPlayerState( playerid ) != PLAYER_STATE_DRIVER )
return SendError( playerid, "You are not in any vehicle as a driver." );
new
Float: total_robbery_xp = GetPlayerExperience( playerid, E_ROBBERY );
switch( listitem )
{
case 0:
{
if ( total_robbery_xp < 180 ) {
return SendError( playerid, "You need at least 180 Robbery XP for this item." );
}
new Float: vZ, vehicleid = GetPlayerVehicleID( playerid );
GetVehicleZAngle( vehicleid, vZ ), SetVehicleZAngle( vehicleid, vZ );
RepairVehicle( vehicleid );
GivePlayerExperience( playerid, E_ROBBERY, -180, .with_dilation = false );
SendServerMessage( playerid, "You have fixed and flipped your vehicle for 180 Robbery XP." );
PlayerPlaySound( playerid, 1133, 0.0, 0.0, 5.0 );
}
case 1:
{
if ( total_robbery_xp < 120 ) {
return SendError( playerid, "You need at least 120 Robbery XP for this item." );
}
new vehicleid = GetPlayerVehicleID( playerid );
PlayerPlaySound( playerid, 1133, 0.0, 0.0, 5.0 );
RepairVehicle( vehicleid );
GivePlayerExperience( playerid, E_ROBBERY, -120, .with_dilation = false );
SendServerMessage( playerid, "You have repaired your car for 120 Robbery XP." );
}
case 2:
{
if ( total_robbery_xp < 80 ) {
return SendError( playerid, "You need at least 80 Robbery XP for this item." );
}
AddVehicleComponent( GetPlayerVehicleID( playerid ), 1010 );
GivePlayerExperience( playerid, E_ROBBERY, -80, .with_dilation = false );
SendServerMessage( playerid, "You have repaired your car for 80 Robbery XP." );
PlayerPlaySound( playerid, 1133, 0.0, 0.0, 5.0 );
}
case 3:
{
if ( total_robbery_xp < 50 ) {
return SendError( playerid, "You need at least 50 Robbery XP for this item." );
}
new Float: vZ, vehicleid = GetPlayerVehicleID( playerid );
GetVehicleZAngle( vehicleid, vZ ), SetVehicleZAngle( vehicleid, vZ );
GivePlayerExperience( playerid, E_ROBBERY, -50, .with_dilation = false );
SendServerMessage( playerid, "You have repaired your car for 50 Robbery XP." );
PlayerPlaySound( playerid, 1133, 0.0, 0.0, 5.0 );
}
}
}
return 1;
}
/* ** Commands ** */
CMD:perks( playerid, params[ ] )
{
if ( IsPlayerInEvent( playerid ) || IsPlayerInBattleRoyale( playerid ) )
return SendError( playerid, "You cannot use this command since you're in an event." );
if ( IsPlayerInArmyVehicle( playerid ) )
return SendError( playerid, "You cannot use this command while in an army vehicle." );
return ShowPlayerDialog( playerid, DIALOG_PERKS, DIALOG_STYLE_LIST, "{FFFFFF}Game Perks", "Deathmatch Perks\nRobbery Perks", "Select", "Cancel" );
}
2018-10-10 01:00:29 +00:00
/* ** Functions ** */
stock IsPlayerHiddenFromRadar( playerid ) {
return p_OffRadar{ playerid };
}