From 68a890d747f68622d1b4d84639ccb1123866601d Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Mon, 15 Oct 2018 15:18:42 +1100 Subject: [PATCH] no keystate for /s ... fixed so previous weapons are given back ... added cooldown as well --- .../irresistible/cnr/features/damage_feed.pwn | 110 +++++++++--------- gamemodes/sf-cnr.pwn | 4 +- 2 files changed, 57 insertions(+), 57 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/damage_feed.pwn b/gamemodes/irresistible/cnr/features/damage_feed.pwn index 9c465c8..f8e9e7a 100644 --- a/gamemodes/irresistible/cnr/features/damage_feed.pwn +++ b/gamemodes/irresistible/cnr/features/damage_feed.pwn @@ -120,7 +120,6 @@ hook OnPlayerDisconnect( playerid, reason ) { p_HitmarkerSound{ playerid } = 0; p_SyncingPlayer{ playerid } = false; - return 1; } @@ -134,7 +133,6 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) PlayerPlaySound( playerid, g_HitmarkerSounds[ listitem ] [ E_SOUND_ID ], 0.0, 0.0, 0.0 ); ShowSoundsMenu( playerid ); } - return 1; } @@ -142,24 +140,22 @@ hook SetPlayerRandomSpawn( playerid ) { if ( p_SyncingPlayer{ playerid } == true ) { - //ResetPlayerWeapons( playerid ); + ResetPlayerWeapons( playerid ); + SetPlayerWantedLevel( playerid, g_syncData[ playerid ] [ E_WANTED_LEVEL ] ); - SetPlayerWantedLevel( playerid, g_syncData[ playerid ][ E_WANTED_LEVEL ] ); + SetPlayerHealth( playerid, g_syncData[ playerid ] [ E_HEALTH ] ); + SetPlayerArmour( playerid, g_syncData[ playerid ] [ E_ARMOUR ] ); + SetPlayerVirtualWorld( playerid, g_syncData[ playerid ] [ E_WORLD ] ); + SetPlayerInterior( playerid, g_syncData[ playerid ] [ E_INTERIOR ] ); + SetPlayerSkin( playerid, g_syncData[ playerid ] [ E_SKIN ] ); + SetPlayerPos( playerid, g_syncData[ playerid ] [ E_X ], g_syncData[ playerid ] [ E_Y ], g_syncData[ playerid ] [ E_Z ] ); + SetPlayerFacingAngle( playerid, g_syncData[ playerid ] [ E_A ] ); - SetPlayerHealth( playerid, g_syncData[ playerid ][ E_HEALTH ] ); - SetPlayerArmour( playerid, g_syncData[ playerid ][ E_ARMOUR ] ); - SetPlayerVirtualWorld( playerid, g_syncData[ playerid ][ E_WORLD ] ); - SetPlayerInterior( playerid, g_syncData[ playerid ][ E_INTERIOR ] ); - SetPlayerSkin( playerid, g_syncData[ playerid ][ E_SKIN ] ); - SetPlayerPos( playerid, g_syncData[ playerid ][ E_X ], g_syncData[ playerid ][ E_Y ], g_syncData[ playerid ][ E_Z ] ); - SetPlayerFacingAngle( playerid, g_syncData[ playerid ][ E_A ] ); - - /* for( new slotid = 0; slotid < 13; slotid ++ ) { - GivePlayerWeapon( playerid, g_syncData[ playerid ][ E_WEAPON_ID ][ slotid ], g_syncData[ playerid ][ E_WEAPON_AMMO ][ slotid ] ); + GivePlayerWeapon( playerid, g_syncData[ playerid ] [ E_WEAPON_ID ] [ slotid ], g_syncData[ playerid ] [ E_WEAPON_AMMO ] [ slotid ] ); } - */ - SetPlayerArmedWeapon( playerid, g_syncData[ playerid ][ E_CURRENT_WEAPON ] ); + + SetPlayerArmedWeapon( playerid, g_syncData[ playerid ] [ E_CURRENT_WEAPON ] ); SetCameraBehindPlayer( playerid ); p_SyncingPlayer{ playerid } = false; @@ -168,14 +164,13 @@ hook SetPlayerRandomSpawn( playerid ) return 1; } -hook OnPlayerKeyStateChange( playerid, newkeys, oldkeys ) +/*hook OnPlayerKeyStateChange( playerid, newkeys, oldkeys ) { if ( newkeys & KEY_SPRINT && newkeys & KEY_AIM ) { SyncPlayer( playerid, .message = false ); } - return 1; -} +}*/ /* ** Functions ** */ function DamageFeed_HideBulletLabel( labelid ) @@ -525,41 +520,6 @@ stock ShowSoundsMenu( playerid ) ShowPlayerDialog( playerid, DIALOG_MODIFY_HITSOUND, DIALOG_STYLE_LIST, ""COL_WHITE"Hitmarker Sound", szSounds, "Select", "Close" ); } -stock SyncPlayer( playerid, bool: message = true ) -{ - if ( !IsPlayerConnected( playerid ) || GetPlayerWeapon( playerid ) == WEAPON_SNIPER || !IsPlayerSpawned( playerid ) || p_SyncingPlayer{ playerid } == true || IsPlayerInAnyVehicle( playerid ) || IsPlayerAFK( playerid ) ) - return 0; - - p_SyncingPlayer{ playerid } = true; - - // ** Obtaining Information ** - GetPlayerHealth( playerid, g_syncData[ playerid ][ E_HEALTH ] ); - GetPlayerArmour( playerid, g_syncData[ playerid ][ E_ARMOUR ] ); - g_syncData[ playerid ][ E_CURRENT_WEAPON ] = GetPlayerWeapon( playerid ); - g_syncData[ playerid ][ E_WORLD ] = GetPlayerVirtualWorld( playerid ); - g_syncData[ playerid ][ E_INTERIOR ] = GetPlayerInterior( playerid ); - g_syncData[ playerid ][ E_TEAM ] = GetPlayerTeam( playerid ); - g_syncData[ playerid ][ E_SKIN ] = GetPlayerSkin( playerid ); - g_syncData[ playerid ][ E_WANTED_LEVEL ] = GetPlayerWantedLevel( playerid ); - - GetPlayerPos( playerid, g_syncData[ playerid ][ E_X ], g_syncData[ playerid ][ E_Y ], g_syncData[ playerid ][ E_Z ] ); - GetPlayerFacingAngle( playerid, g_syncData[ playerid ][ E_A ] ); - - for( new slotid = 0; slotid < 13; slotid ++ ) { - GetPlayerWeaponData( playerid, slotid, g_syncData[ playerid ][ E_WEAPON_ID ][ slotid ], g_syncData[ playerid ][ E_WEAPON_AMMO ][ slotid ] ); - } - - //ResetPlayerWeapons( playerid ); - ClearAnimations( playerid ); - - // ** Reinstating Information ** * - SpawnPlayer( playerid ); - - if ( message ) - SendServerMessage( playerid, "You are now synced." ); - return 1; -} - /* ** Commands ** */ CMD:hitmarker( playerid, params[ ] ) { @@ -570,6 +530,46 @@ CMD:hitmarker( playerid, params[ ] ) CMD:s( playerid, params[ ] ) return cmd_sync( playerid, params ); CMD:sync( playerid, params[ ] ) { - SyncPlayer( playerid ); + if ( ! IsPlayerConnected( playerid ) || ! IsPlayerSpawned( playerid ) || p_SyncingPlayer{ playerid } == true || IsPlayerAFK( playerid ) ) + return SendError( playerid, "You cannot use this feature at the moment." ); + + if ( IsPlayerInAnyVehicle( playerid ) ) + return SendError( playerid, "You cannot synchronize yourself in a vehicle." ); + + if ( GetPlayerWeapon( playerid ) == WEAPON_SNIPER ) + return SendError( playerid, "You cannot synchronize yourself holding a sniper." ); + + new + curr_server_time = GetServerTime( ); + + if ( GetPVarInt( playerid, "sync_cooldown" ) > curr_server_time ) + return SendServerMessage( playerid, "Please wait %d seconds seconds before using this feature again.", GetPVarInt( playerid, "sync_cooldown" ) - curr_server_time ); + + SetPVarInt( playerid, "sync_cooldown", curr_server_time + 30 ); + + p_SyncingPlayer{ playerid } = true; + + // ** Obtaining Information ** + GetPlayerHealth( playerid, g_syncData[ playerid ] [ E_HEALTH ] ); + GetPlayerArmour( playerid, g_syncData[ playerid ] [ E_ARMOUR ] ); + g_syncData[ playerid ] [ E_CURRENT_WEAPON ] = GetPlayerWeapon( playerid ); + g_syncData[ playerid ] [ E_WORLD ] = GetPlayerVirtualWorld( playerid ); + g_syncData[ playerid ] [ E_INTERIOR ] = GetPlayerInterior( playerid ); + g_syncData[ playerid ] [ E_SKIN ] = GetPlayerSkin( playerid ); + g_syncData[ playerid ] [ E_WANTED_LEVEL ] = GetPlayerWantedLevel( playerid ); + + GetPlayerPos( playerid, g_syncData[ playerid ] [ E_X ], g_syncData[ playerid ] [ E_Y ], g_syncData[ playerid ] [ E_Z ] ); + GetPlayerFacingAngle( playerid, g_syncData[ playerid ] [ E_A ] ); + + for( new slotid = 0; slotid < 13; slotid ++ ) { + GetPlayerWeaponData( playerid, slotid, g_syncData[ playerid ] [ E_WEAPON_ID ] [ slotid ], g_syncData[ playerid ] [ E_WEAPON_AMMO ] [ slotid ] ); + } + + //ResetPlayerWeapons( playerid ); + ClearAnimations( playerid ); + + // Reinstating Information + SpawnPlayer( playerid ); + SendServerMessage( playerid, "You are now synchronized." ); return 1; } diff --git a/gamemodes/sf-cnr.pwn b/gamemodes/sf-cnr.pwn index b29626b..72daabc 100644 --- a/gamemodes/sf-cnr.pwn +++ b/gamemodes/sf-cnr.pwn @@ -2544,14 +2544,14 @@ public OnPlayerSpawn( playerid ) SetPlayerColorToTeam( playerid ); SetPlayerVirtualWorld( playerid, 0 ); - CallLocalFunction( "SetPlayerRandomSpawn", "d", playerid ); if ( p_VIPLevel[ playerid ] >= VIP_REGULAR && p_VIPWep1{ playerid } != 0 ) GivePlayerWeapon( playerid, p_VIPWep1{ playerid }, 200 ); if ( p_VIPLevel[ playerid ] >= VIP_BRONZE && p_VIPWep2{ playerid } != 0 ) GivePlayerWeapon( playerid, p_VIPWep2{ playerid }, 200 ); if ( p_VIPLevel[ playerid ] >= VIP_GOLD && p_VIPWep3{ playerid } != 0 ) GivePlayerWeapon( playerid, p_VIPWep3{ playerid }, 200 ); - if ( p_VIPLevel[ playerid ] >= VIP_BRONZE ) SetPlayerArmour( playerid, 100.0 ); // Free armour on spawn. + CallLocalFunction( "SetPlayerRandomSpawn", "d", playerid ); + SendClientMessageFormatted( playerid, -1, ""COL_GOLD"[SPAWN INFO]"COL_WHITE" It has taken you %d milliseconds to spawn!", ( GetTickCount( ) - iTick ) ); return 1; }