Official Soldat Forums
Server Talk => Scripting Discussions and Help => Topic started by: D4NG3R NL on May 09, 2009, 05:52:03 pm
-
Ok I study'ed the starter tips and came out with a start for my script...
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
if Text = '/class runner' then begin
WriteLn('Good luck as a Runner!');
end;
end;
First question: Is this (wee small) part of script WORKING. if I would export it?
(would it say "Good luck as a Runner!")
Second question: How can I get a player ID, and give them the following:
MP5, Knife and Vest.
begin
SpawnObject(GetPlayerStat(1,'x'),GetPlayerStat(1,'y'),19);
end;
This would spawn a Vest, But for player 1. HOW can I make it so that the player that says the /class runner. gets the item?
-
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 (http://devs.soldat.pl/wiki/index.php/GiveBonus).
To give it to the player that says it just stick it in the if thingey.
-
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 (http://devs.soldat.pl/wiki/index.php/GiveBonus).
To give it to the player that says it just stick it in the if thingey.
Aint "forceweapon" crashing in 1.5?
Weapons:
2 = MP5
12 = Knife
0 = Amount of ammo (0 is standard)
Bonus
3 = Vest
Weapon:
procedure ForceWeapon(ID, 2, 12, 0: Byte);
Bonus:
procedure GiveBonus(ID, 3: byte);
but HOW to put them into the script ???
Im not that good with the pascal scripting yet :(, but Im learning quickly (as I didnt knew ANYTHING about it 60 mins ago!)
-
Aint "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:
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 tested
If you want some more examples of stuff then check out my guide (http://forums.soldat.pl/index.php?topic=29911.0).
-
Aint "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:
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 tested
If you want some more examples of stuff then check out my guide (http://forums.soldat.pl/index.php?topic=29911.0).
Thx :D
I could just change this to make other classes to :)?
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
if Text = '/class heavy' then begin
WriteConsole(ID, 'Good luck as a Heavy!', $FFFFFF);
ForceWeapon(ID, 5, 13, 0);
GiveBonus(ID, 2);
end;
end;
This would give an AK-74 & Chainsaw instead of MP5 & Knife on the command /class heavy
Btw what is this
$FFFFFF,
Colour code?
-
Yes it's a colour code
-
They're both the same function:
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;
-
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.
-
Probably by using a variable, I'm not sure
-
Stuff to do:
Wait until ForceWeapon doesnt make soldat crash anymore (waiting for 1.5.1 xD)
Need to figure out how to limit the times you can pick a class to 1.
Need to figure out how to make weapons un-dropable.
Need to figure out how to place people in spectator mode WHERE THEY CANNOT LEAVE UNTIL THE NEXT ROUND STARTS!
Need to figure out how to make a timer, so the enemy's (zombies) will start spawning after 30 seconds :) to give you enough time to pick a class :D
Current pieces of script:
Info script:
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;
Pickup script(I removed the forceweapon for a while)
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;
Pickup script with forceweapon
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;
-
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)
-
Btw what is this
$FFFFFF,
Colour code?
FIY, in this context it's used as a color code, but a $ actually means a number defined in hexadecimals. You can set any (integer like) variable with that. Read more here:
http://simple.wikipedia.org/wiki/Hexadecimal
And err.. good luck with the script, it seems quite a big challenge for a beginner like you ;)
-
And err.. good luck with the script, it seems quite a big challenge for a beginner like you ;)
Thats why I like doing it :D. IDC if it takes me a month, OR EVEN LONGER to create. I just want to make it :)
-
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)
I don't really get that part, HOW do I make the script check if you already picked (any) class?
var
i: Integer;
begin
Readln(i);
if i > 0 then
WriteConsole('You already picked a class');
else
(WHAT TO PUT HERE?)
end.
This part should be OK
-
1 - Predator
2 - Berserker
3 - Bulletproof vest
4 - Grenades
5 - Cluster grenades
I need a damn Flamegod pickup command :@
Just a line of text (after "if)
like
GiveBonus(ID, 3);
For vest
-
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;
And for flamegod I guess you have to spawn it on them.
-
i am on my ipod touch ,
i made the you can only pick one class. I will send it when i will be at home
-
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.
For this you will need to create a boolean. Which means its a true or a false.
Like in all beginning of scripts you need to define what you are gonna use. Like
var
Classtaken: array[1..32] of boolean;
ok, i defined it.
Now with script it should look like that
var
Classtaken: array[1..32] of boolean;
function OnPlayerCommand(ID: Byte; Text: string): boolean;
//Here is for runner
Var
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;
I removed the ForceWeapon 'cause i was testing it =]
It works perfectly
If you have question just ask :D
-
Please don't double post so much, people. You can edit your previous messages and I don't think this topic will die very quickly :p
What i don't get is what you're planning to do after a player dies. Will he have to select a class again or will the same class still apply? In the last case you will need to remember what class each player has chosen and thus you'll need to store that. That means you could use iDante's example the way danmer suggests. Then instead of an array of boolean, create an array of integers and store there for each player a number which represents the class. If the number is zero then the player hasn't chosen yet.
adapted from iDante:
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;
Btw, I'm always willing to help ppl learn2script (in Dutch). You can find my xfire on elitectf.com
-
Yep, iDante's one is quite more simple than mine :)
I am a beginner too. I'm helping with what i know and i learned alot doing this. If you can explain me what i didn't do correct it could be nice staying in the topic's subject.
And yeah, i don't know what to do when player dies.
D4NG3R : Did you make an includes.txt ?
Edit : JFK, i know what to do, i'll script it =]
-
Please don't double post so much, people. You can edit your previous messages and I don't think this topic will die very quickly :p
What i don't get is what you're planning to do after a player dies. Will he have to select a class again or will the same class still apply? In the last case you will need to remember what class each player has chosen and thus you'll need to store that. That means you could use iDante's example the way danmer suggests. Then instead of an array of boolean, create an array of integers and store there for each player a number which represents the class. If the number is zero then the player hasn't chosen yet.
adapted from iDante:
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;
Btw, I'm always willing to help ppl learn2script (in Dutch). You can find my xfire on elitectf.com
After the player dies he will be put in spectator, The next round you can take a new class. ;)
-
Yep, iDante's one is quite more simple than mine :)
I am a beginner too. I'm helping with what i know and i learned alot doing this. If you can explain me what i didn't do correct it could be nice staying in the topic's subject.
And yeah, i don't know what to do when player dies.
D4NG3R : Did you make an includes.txt ?
Edit : JFK, i know what to do, i'll script it =]
I did xD
-
Oh ok... So when player dies the chosen class is erased, then player chooses for another one next round ?
Edit : What do you get for a compile error?
-
Oh ok... So when player dies the chosen class is erased, then player chooses for another one next round ?
Edit : What do you get for a compile error?
On map switch the pickclass is set back to 0 :)
-
Okay =)
When player joins, do you want it do be in spectator, so he doesn't get killed by " Zombiez "
-
JFK helped me with my script (thx mate) but for some reason its still not working (NO this script aint finished yet, i just wanted to compile it to test >:(
The second upload is a picture of what i get
the first upload is the .pas
-
well it stops at test2, try disabling that script (rename Includes.txt for example) and see if the rest compile.
Also, you'll get faster replies at IRC, try #soldat.devs and #soldat.central @ QuakeNet
-
In line 6 you have to put a ; (Semicolon) at the end of the line
-
Not really. First of all the compiler always adds a line for some reason, so the place to look is at line 5. Then the error (usually) means that the compiler expected a semicolon before the given line (and char). So that would be a semicolon after:
var picked_class : array[1..32] of integer;
Also remove the semicolon after 'begin', there's never a semicolon after 'begin'.
-
I write that in the Morning, so i forget that with the line :D
-
Edit + repost it please, Because I keep getting that error, even after changing it to what you said =/
-
If you get an error post the code so we can faster help you, because we don'T know if the code uper is the current one you use.