0 Members and 1 Guest are viewing this topic.
function OnPlayerCommand(ID: Byte; Text: string): boolean;begin if Text = '/class runner' then begin WriteLn('Good luck as a Runner!'); end;end;
begin SpawnObject(GetPlayerStat(1,'x'),GetPlayerStat(1,'y'),19);end;
WriteLn writes it to the server console. Use WriteConsole to write it to a player.To give them an mp5 and a knife use ForceWeapon. To give them a vest use GiveBonus.To give it to the player that says it just stick it in the if thingey.
Aint "forceweapon" crashing in 1.5?
function OnPlayerCommand(ID: Byte; Text: string): boolean;begin if Text = '/class runner' then begin WriteConsole(ID, 'Good luck as a Runner!', $FFFFFF); ForceWeapon(ID, 2, 12, 0); GiveBonus(ID, 3); end;end;
Quote from: D4NG3R NL on May 09, 2009, 06:11:03 pmAint "forceweapon" crashing in 1.5?Yep, but hopefully it'll get fixed sometime soon so we can continue to party with it.Might as well show you how it's done:Code: [Select]function OnPlayerCommand(ID: Byte; Text: string): boolean;begin if Text = '/class runner' then begin WriteConsole(ID, 'Good luck as a Runner!', $FFFFFF); ForceWeapon(ID, 2, 12, 0); GiveBonus(ID, 3); end;end;NOT testedIf you want some more examples of stuff then check out my guide.
function OnPlayerCommand(ID: Byte; Text: string): boolean;begin if Text = '/class runner' then begin WriteConsole(ID, 'Good luck as a Runner!', $FFFFFF); ForceWeapon(ID, 2, 12, 0); GiveBonus(ID, 3); end; if Text = '/class heavy' then begin WriteConsole(ID, 'Good luck as a Heavy!', $FFFFFF); ForceWeapon(ID, 5, 13, 0); GiveBonus(ID, 2); end;end;
function OnPlayerCommand(ID: Byte; Text: string): boolean;begin; if Text = '/runner info' then begin WriteConsole(ID, 'With the Runner class you get: MP5, Knife & 1 Vest kit!', $FFFFFF); WriteConsole(ID, 'Type /class runner to take the Runner class!', $808080); end; if Text = '/assault info' then begin WriteConsole(ID, 'With the Assault class you get: AK-74, Knife & 1 Cluster kit!', $FFFFFF); WriteConsole(ID, 'Type /class assault to take the Assault class!', $808080); end; if Text = '/hunter info' then begin WriteConsole(ID, 'With the Hunter class you get: M82a1, USSOCOM & 1 Predator kit!', $FFFFFF); WriteConsole(ID, 'Type /class hunter to take the Hunter class!', $808080); end; if Text = '/heavy info' then begin WriteConsole(ID, 'With the Heavy class you get: Spas-12, Chainsaw & 1 Berseker kit!', $FFFFFF); WriteConsole(ID, 'Type /class heavy to take the Heavy class!', $808080); end; end;
function OnPlayerCommand(ID: Byte; Text: string): boolean;begin; if Text = '/class runner' then begin WriteConsole(ID, 'Good luck as a Runner!', $FFFFFF); GiveBonus(ID, 3); end; if Text = '/class assault' then begin WriteConsole(ID, 'Good luck as a Assaulter!', $FFFFFF); GiveBonus(ID, 5); end; if Text = '/class hunter' then begin WriteConsole(ID, 'Good luck as a Hunter!', $FFFFFF); GiveBonus(ID, 1); end; if Text = '/class heavy' then begin WriteConsole(ID, 'Good luck as a Heavy!', $FFFFFF); GiveBonus(ID, 2); end;end;
function OnPlayerCommand(ID: Byte; Text: string): boolean;begin; if Text = '/class runner' then begin WriteConsole(ID, 'Good luck as a Runner!', $FFFFFF); ForceWeapon(ID, 2, 12, 0); GiveBonus(ID, 3); end; if Text = '/class assault' then begin WriteConsole(ID, 'Good luck as a Assaulter!', $FFFFFF); ForceWeapon(ID, 3, 12, 0); GiveBonus(ID, 5); end; if Text = '/class hunter!' then begin WriteConsole(ID, 'Good luck as a Hunter!', $FFFFFF); ForceWeapon(ID, 8, 11, 0); GiveBonus(ID, 1); end; if Text = '/class heavy' then begin WriteConsole(ID, 'Good luck as a Heavy!', $FFFFFF); ForceWeapon(ID, 5, 13, 0); GiveBonus(ID, 2); end;end;
Btw what is this $FFFFFF,Colour code?
And err.. good luck with the script, it seems quite a big challenge for a beginner like you
just store everyone's class in an array of 32 ints, set all the values to 0 on activateserver and onmapchange. Then if someone does /class - check if his value is zero, then he can choose a class (set the according array value to the ID of the class when he chooses a class too). I hope this made sense to you. Also, you might want to use case here (http://www.learn-programming.za.net/programming_pascal_learn05.html)
var i: Integer; begin Readln(i); if i > 0 then WriteConsole('You already picked a class'); else (WHAT TO PUT HERE?)end.
var picked_class: array[1..32] of boolean;//This bit should run when the player has tried to pick a class.begin if picked_class[ID] then WriteConsole('You already picked a class') else begin { Give them the bonus here } picked_class[ID] := true; end;end;
Ok, I compiled the script & tested it out (I removed the forceweapon lines just to test). It will give packs of bonuses smoothly. Now the problem is, I want to make the script in such manner that you can only take a class ONCE. (and cannot switch to a different one)How to make the script check if someone already has a class?+ If I wanted to make weapons undropable, How would I do this.
varClasstaken: array[1..32] of boolean;
varClasstaken: array[1..32] of boolean; function OnPlayerCommand(ID: Byte; Text: string): boolean;//Here is for runnerVar B: Byte; begin For B:= 1 To 32 Do if Text = '/class runner' then begin If Classtaken= False Then begin Classtaken:=True; IF GetPlayerStat(B, 'Human') Then Begin Classtaken:=True; WriteConsole(ID, 'Good luck as a Runner!', $FFFFFF); GiveBonus(ID, 3); end; end else if GetPlayerStat(B, 'Human') Then Begin WriteConsole(ID, 'You already have a class' ,$FFFFFF); end;end;// Here is for assaulter For B:= 1 To 32 Do if Text = '/class assault' then begin If Classtaken= False Then begin Classtaken:=True; IF GetPlayerStat(B, 'Human') Then Begin Classtaken:=True; WriteConsole(ID, 'Good luck as a Assaulter!', $FFFFFF); GiveBonus(ID, 5); end; end else if GetPlayerStat(B, 'Human') Then Begin WriteConsole(ID, 'You already have a class' ,$FFFFFF); end;end;//Here is for hunter For B:= 1 To 32 Do if Text = '/class hunter' then begin If Classtaken= False Then begin Classtaken:=True; IF GetPlayerStat(B, 'Human') Then Begin Classtaken:=True; WriteConsole(ID, 'Good luck as a Hunter!', $FFFFFF); GiveBonus(ID, 1); end;end else if GetPlayerStat(B, 'Human') Then Begin WriteConsole(ID, 'You already have a class' ,$FFFFFF); end;end;// Here is for Heavy For B:= 1 To 32 Do if Text = '/class heavy' then begin If Classtaken= False Then begin Classtaken:=True; IF GetPlayerStat(B, 'Human') Then Begin Classtaken:=True; WriteConsole(ID, 'Good luck as a Heavy!', $FFFFFF); GiveBonus(ID, 2); end; end else if GetPlayerStat(B, 'Human') Then Begin WriteConsole(ID, 'You already have a class' ,$FFFFFF); end; end; end;
var picked_class: array[1..32] of integer;//This bit should run when the player has tried to pick a class.begin if picked_class[ID] > 0 then WriteConsole('You already picked a class') else begin { Give them the bonus here } picked_class[ID] := classnumber; //classnumber being the class that the player has chosen end;end;