0 Members and 5 Guests are viewing this topic.
procedure RemovePrimary( ID, Primary, Secondary :byte );begin if ( ( Secondary <= 10 ) and ( Secondary > 0 ) ) then ForceWeapon( ID, Primary, 255, GetPlayerStat( ID, 'Ammo' ) ); if ( ( Primary <= 10 ) and ( Primary > 0) ) then ForceWeapon( ID, 255, Secondary, 0 );end;
Well, I want to make a script so whenever someone does !medic, his primary disappears (or drops off) and he'll be left only with the secondary. In addition to that , I wanna make him not able to pick up any other primaries from the ground, not able to pick a primary when he respawns, and when he switches team or does !medic again so he won't be medic anymore, to allow him to use primaries as before.
varMedic:array[1..MaxPlayers] of boolean;procedure RemovePrimary( ID, Primary, Secondary :byte );begin if ( ( Secondary <= 10 ) and ( Secondary > 0 ) ) then ForceWeapon( ID, Primary, 255, GetPlayerStat( ID, 'Ammo' ) ); if ( ( Primary <= 10 ) and ( Primary > 0) ) then ForceWeapon( ID, 255, Secondary, 0 );end;procedure OnWeaponChange( ID, PrimaryNum, SecondaryNum: Byte );begin if Medic[ID]=true then RemoveSecondary( ID, PrimaryNum, SecondaryNum );end;procedure OnPlayerRespawn( ID: Byte );begin if Medic[ID]=true then RemoveSecondary( ID, GetPlayerStat( ID, 'Primary' ), GetPlayerStat( ID, 'Secondary' );end;procedure OnPlayerSpeak( ID: byte; Text: string );beginif Lowercase(Text)='!medic' then begin Medic[ID] := ( Medic[ID] = false ); if ( Medic[ID] = true ) then RemoveSecondary( ID, GetPlayerStat( ID, 'Primary' ), GetPlayerStat( ID, 'Secondary' ); end;end;procedure OnJoinTeam( ID, Team: byte );begin if ( Medic[ID] = true ) then Medic[ID] := false;end;
Found in above after a quick look:- array 1..MaxPlayers won't compile as MaxPlayers is variable. Also it is not a good idea to do player array from 1 to whatever is set in INI as there may be bots on the server.- Secondary > 0 and Primary > 0 has no sense as both are unsigned bytes- in OnPlayerRespawn player has most likely still weapon menu opened- doesn't Medic[ID] := not Medic[ID] look sexier? also just if Medic[ID] instead of if ( Medic[ID] = true )
procedure RemovePrimary( ID, Primary, Secondary :byte );
Code: [Select]procedure RemovePrimary( ID, Primary, Secondary :byte ); tkpunish -> [Error] (120:12): Unknown identifier 'Secondary' Compilation Failed.what's his problem? ._. Can't verify it cause enesce.com/help is offline..
ConstMAXPLAYERSANDBOTS=14;varMedic:array[1..MAXPLAYERSANDBOTS] of boolean;procedure RemovePrimary( ID, PrimaryNum, SecondaryNum :byte );begin if ( ( SecondaryNum <= 10 ) and ( SecondaryNum > 0 ) ) then ForceWeapon( ID, PrimaryNum, 255, GetPlayerStat( ID, 'Ammo' ) ); if ( ( PrimaryNum <= 10 ) and ( PrimaryNum > 0) ) then ForceWeapon( ID, 255, SecondaryNum, 0 );end;procedure OnWeaponChange( ID, PrimaryNum, SecondaryNum: Byte );begin if Medic[ID]=true then RemovePrimary( ID, PrimaryNum, SecondaryNum );end;procedure OnPlayerRespawn( ID: Byte );begin if Medic[ID]=true then RemovePrimary( ID, GetPlayerStat( ID, 'Primary' ), GetPlayerStat( ID, 'Secondary' ) );end;procedure OnPlayerSpeak( ID: byte; Text: string );beginif Lowercase(Text)='!medic' then begin Medic[ID] := ( Medic[ID] = false ); if ( Medic[ID] = true ) then RemovePrimary( ID, GetPlayerStat( ID, 'Primary' ), GetPlayerStat( ID, 'Secondary' ) ); end;end;procedure OnJoinTeam( ID, Team: byte );begin if ( Medic[ID] = true ) then Medic[ID] := false;end;
The thing is, with your script, after you respawn both of your primary and secondary is removed.Also picking up weapons still works, need to change OnWeaponChange...
ConstMAXPLAYERSANDBOTS=20;varMedic:array[1..MAXPLAYERSANDBOTS] of boolean;procedure RemovePrimary( ID, PrimaryNum, SecondaryNum :byte );begin if ( ( SecondaryNum <= 10 ) and ( SecondaryNum > 0 ) ) then ForceWeapon( ID, PrimaryNum, 255, GetPlayerStat( ID, 'Ammo' ) ); if ( ( PrimaryNum <= 10 ) and ( PrimaryNum > 0) ) then ForceWeapon( ID, 255, SecondaryNum, 0 );end;procedure AppOnIdle( Ticks: Integer );var i:byte;begin for i := 1 to MAXPLAYERSANDBOTS do if ( ( Medic[i]=true ) and ( GetPlayerStat( i, 'Alive' ) ) ) then RemovePrimary( i, GetPlayerStat( i, 'Primary' ), GetPlayerStat( i, 'Secondary' ) );end;procedure OnPlayerSpeak( ID: byte; Text: string );begin if Lowercase(Text)='!medic' then Medic[ID] := ( Medic[ID] = false );end;procedure OnJoinTeam( ID, Team: byte );begin if ( Medic[ID] = true ) then Medic[ID] := false;end;