no keystate for /s ... fixed so previous weapons are given back ... added cooldown as well

This commit is contained in:
Lorenc Pekaj 2018-10-15 15:18:42 +11:00
parent b9edc6add6
commit 68a890d747
2 changed files with 57 additions and 57 deletions

View File

@ -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,8 +140,7 @@ hook SetPlayerRandomSpawn( playerid )
{
if ( p_SyncingPlayer{ playerid } == true )
{
//ResetPlayerWeapons( playerid );
ResetPlayerWeapons( playerid );
SetPlayerWantedLevel( playerid, g_syncData[ playerid ] [ E_WANTED_LEVEL ] );
SetPlayerHealth( playerid, g_syncData[ playerid ] [ E_HEALTH ] );
@ -154,11 +151,10 @@ hook SetPlayerRandomSpawn( playerid )
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 ] );
}
*/
SetPlayerArmedWeapon( playerid, g_syncData[ playerid ] [ E_CURRENT_WEAPON ] );
SetCameraBehindPlayer( playerid );
@ -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,10 +520,32 @@ stock ShowSoundsMenu( playerid )
ShowPlayerDialog( playerid, DIALOG_MODIFY_HITSOUND, DIALOG_STYLE_LIST, ""COL_WHITE"Hitmarker Sound", szSounds, "Select", "Close" );
}
stock SyncPlayer( playerid, bool: message = true )
/* ** Commands ** */
CMD:hitmarker( playerid, params[ ] )
{
if ( !IsPlayerConnected( playerid ) || GetPlayerWeapon( playerid ) == WEAPON_SNIPER || !IsPlayerSpawned( playerid ) || p_SyncingPlayer{ playerid } == true || IsPlayerInAnyVehicle( playerid ) || IsPlayerAFK( playerid ) )
return 0;
ShowSoundsMenu( playerid );
return 1;
}
CMD:s( playerid, params[ ] ) return cmd_sync( playerid, params );
CMD:sync( playerid, params[ ] )
{
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;
@ -538,7 +555,6 @@ stock SyncPlayer( playerid, bool: message = true )
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 );
@ -552,24 +568,8 @@ stock SyncPlayer( playerid, bool: message = true )
//ResetPlayerWeapons( playerid );
ClearAnimations( playerid );
// ** Reinstating Information ** *
// Reinstating Information
SpawnPlayer( playerid );
if ( message )
SendServerMessage( playerid, "You are now synced." );
return 1;
}
/* ** Commands ** */
CMD:hitmarker( playerid, params[ ] )
{
ShowSoundsMenu( playerid );
return 1;
}
CMD:s( playerid, params[ ] ) return cmd_sync( playerid, params );
CMD:sync( playerid, params[ ] )
{
SyncPlayer( playerid );
SendServerMessage( playerid, "You are now synchronized." );
return 1;
}

View File

@ -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;
}