Author Topic: Help with basic script  (Read 7819 times)

0 Members and 1 Guest are viewing this topic.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #20 on: May 08, 2010, 07:29:57 pm »
but then how would i show it in a writeconsole message when they die considering Kills is array in your code

would it be.....?
Code: (pascal) [Select]
if Player[Killer] = Player[Victim] then writeconsole(Victim,'your kill streak: '+inttostr(Kills[Victim]),$FFEO2OFE)
also, kills would be alot more than 32, or is that just storing the values for all 32 ppl? i am still a tiny bit confused about the arrays

From: May 08, 2010, 07:40:18 pm
also im getting a type mismatch with the writeconsole part of the code posted above, if i get rid of inttostr it still says type mismatch so how would i show it in a writeconsole message?
« Last Edit: May 08, 2010, 07:40:44 pm by frosty »
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Help with basic script
« Reply #21 on: May 08, 2010, 07:42:20 pm »
also, kills would be alot more than 32, or is that just storing the values for all 32 ppl? i am still a tiny bit confused about the arrays

Array[1..32] Stores 32 datas for 32 different, in the case, players.

Go:

Code: (pascal) [Select]
Var
 Kills: Array[1..32] of Integer;

Procedure OnPlayerKill();
 Begin
  if Killer <> Victim Then Begin //Checks if killer is different from victim
   Kills[Killer] := Kills[Killer] + 1; //Increasing by one Killer's Kills.
  WriteConsole(Killer,'Your Kill Streak: '+IntToStr(Kills[Killer]),$FFFFFF);
 end else WriteConsole(ID,'You cant get kills by killing yourself!',$FFFFFF);
end;

//That should do it.

//Arrays store data for [Min..Max] values you put in.

//Like, go:

Procedure OnPlayerSpeak();
 Begin
  if Text = '!mykills' Then WriteConsole(ID,'Your kills: '+IntToStr(Kills[ID]),$FFFFFF);
end;

//See?

//This \/

{
Var
 Kills: Integer;
}

//That /\ is a global var. It's unique for every player in the server.

//If, for instance, you go "Kills := 0;", then every player's kills streak will be reseted.

//Doing "Kills[ID] := 0;" would only reset one player's kills streak

//Hope you've learned :)

//Any more questions, feel free to ask :D
www.soldatx.com.br - The brazilian Soldat community.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #22 on: May 08, 2010, 07:52:51 pm »
nevermind, inttostr works perfect, its just the color value was incorrect, now its working on my test server perfectly, heres the working code:


From: May 08, 2010, 07:56:42 pm
and thanks squiddy :D that makes life alot easier :D
« Last Edit: May 08, 2010, 07:56:42 pm by frosty »
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: Help with basic script
« Reply #23 on: May 09, 2010, 01:01:13 am »
frosty.. try using the "code=pascal" tag for syntax highlighting if you're not going to use nopaste services (with square braces instead of quotes ofc, and a /code in the end).
Looking at your screenshots kills people from inside bit by bit

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #24 on: May 09, 2010, 01:38:20 am »
dnmr why did i start doing this in the first place???

u obviously havent read why

posting code in the code highlighing (code)(/code)  does not indent it properly, and then you complain because you cant read the indents, same with pastebin it does not indent it properly, then you complain because you cant read the code because it hasnt indented properly, so dont complain cuz this is what you get, and im not changing it >:( and im sick of complaints so build a f**king bridge and get the f**k over it

i mean how f**king hard is ot to click the screenshot and read it? not f**king hard so whats the big f**king deal?

so:
-i use code=pascal, it doesnt indent properly= you complain
-i use pastebin, it doesnt indent properly=you complain
-i post easy to read screenshots AND include the code=you complain
-i post it as plain code i know your going to complain

this is very annoying especially when i have taken the best option which IS indented properly so you can actually READ IT

and this getting beyond a joke so in future why dont i just post it as normal text just to annoy you? just to show just how annoyed i am at this bullshit?

From: May 09, 2010, 01:50:26 am
i ahve no other option except to post screenshots as thats the only thing that WILL BE INDENTED PROPERLY SO STFU
« Last Edit: May 09, 2010, 01:50:26 am by frosty »
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Help with basic script
« Reply #25 on: May 09, 2010, 01:52:38 am »
We're just giving tips away, we know what's good and what not.
Btw. I never had problems with the indenting here..

Anyway, here's an example with types.
Code: (pascal) [Select]
type // start type
   TPlayer = Record // name of the type
     Kills: integer;
     Anoter_Variable: byte;
   end; // declares the end of the TPlayer type.

var
   Player: Array [1..32] of TPlayer; // next you need to declare it as an variable.

//Looks like that when you use it: Player[ID].Variable

procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
   if Killer <> Victim then begin
     Player[Killer].Kills := Player[Killer] + 1;
     WriteConsole(ID, 'Kill streak: ' + inttostr(Player[Killer].Kills), $FFFFFF);
   end;
   Player[Victim].Kills := 0;
end;
Now you should check it  ::)
« Last Edit: May 09, 2010, 01:55:01 am by Swompie »

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #26 on: May 09, 2010, 01:56:04 am »
thanks swompie, see dnmr? no one else has any problem, if you post anything like that again ima just ignore it
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Help with basic script
« Reply #27 on: May 09, 2010, 01:59:36 am »
thanks swompie, see dnmr? no one else has any problem, if you post anything like that again ima just ignore it
Tbh idc how you post it, but it's not the forum fucking up the indent, srsly it depends on how you do it,
do you use a mix of tabs and spaces? I never noticed anyone having trouble with it >_>

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #28 on: May 09, 2010, 02:10:06 am »
i always use just tabs cuz its easer, but somehow the size of a tab gets doubled and you get lines everywhere if i use pastebin so is started posting screenshots

and all id o i copy and paste and it screws up so yeh

also most browsers put half of most of the lines to the next line cuz it wont fit all on page so u still get lines everywhere so yeh
Dnmr tends to complain about my postings, pastebin or otherwise
« Last Edit: May 09, 2010, 02:12:32 am by frosty »
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline SpiltCoffee

  • Veteran
  • *****
  • Posts: 1579
  • Spilt, not Split!
    • SpiltCoffee's Site
Re: Help with basic script
« Reply #29 on: May 09, 2010, 10:17:42 am »
Looking at the latest screenshot you attached, frosty, I can't help but notice that you're indentation is poor. You should be using two spaces for every indent, and make sure that you indent your block statements and conditional statements correctly. :)
When life hands you High Fructose Corn Syrup, Citric Acid, Ascorbic Acid, Maltodextrin, Sodium Acid Pyrophosphate,
Magnesium Oxide, Calcium Fumarate, Yellow 5, Tocopherol and Less Than 2% Natural Flavour... make Lemonade!

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #30 on: May 09, 2010, 01:18:40 pm »
so using a single tab for each indent is bad? if i use spaces then notepad++ doesnt show me the indent guide(the lines going from the begins to the ends) and using spaces somehow corrupts the script i had to use tabs as indent just to fix up one of my scripts so idk what to do
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Help with basic script
« Reply #31 on: May 09, 2010, 02:12:42 pm »
so using a single tab for each indent is bad? if i use spaces then notepad++ doesnt show me the indent guide(the lines going from the begins to the ends) and using spaces somehow corrupts the script i had to use tabs as indent just to fix up one of my scripts so idk what to do
How can using 2 spaces corrupt script? After every operator creating a list like begin/case/var/const you should move to next column and you're not doing that.

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Help with basic script
« Reply #32 on: May 09, 2010, 02:48:28 pm »
Just because it doesn't show the indent guide doesn't mean it corrupts the script in any way, I never had problems with spaces, you just saved the file in the wrong format or w/e.
Also you don't need that indent guide, works fine without it imo if you can script abit..
Tbh I think that you can that? Also I'm pretty sure that you may can change when the indent guide pops up somewhere, google is your friend if you're going to change your style indenting scripts.

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: Help with basic script
« Reply #33 on: May 09, 2010, 03:20:34 pm »
dear frosty. Nobody's complaining about how the forum or pastebin treat tabs. The thing is, when you post text in any form, anyone here can copy it and paste it in his editor of choice. If he's not comfortable with tabs, they can be replaced by any number or spaces in no time in most text editors. When you post a graphical representation of the text, it is not that easy to copy the code and work with it from there. Nobody's going to use a text recognition program, it's just ridiculous.

The key problem is not in how different applications treat tabs/spaces, the problem is in your indenting. It's as good as no indenting at all, because it is not consistent and at some places you don't tab your code at all or tab it too much, thus breaking the code structure and provoking the loss of some begins and ends.

Offline SpiltCoffee

  • Veteran
  • *****
  • Posts: 1579
  • Spilt, not Split!
    • SpiltCoffee's Site
Re: Help with basic script
« Reply #34 on: May 09, 2010, 06:14:19 pm »
If you want Notepad++ to use two spaces instead of a real tab whenever you press the tab button, do the following:

1. In Notepad++, go to Settings > Preferences.
2. In this new window, click on the Language Menu/Tab Settings tab.
3. On the right side, scroll down the language list and select Pascal.
4. Check the box that says "Replace by space".
5. Click on the blue underlined number so that a little box appears, and type in the number 2, and then press enter.
6. Click close and enjoy using two spaces whenever you use tab, and seeing Notepad++ offer the indent guide. :)
When life hands you High Fructose Corn Syrup, Citric Acid, Ascorbic Acid, Maltodextrin, Sodium Acid Pyrophosphate,
Magnesium Oxide, Calcium Fumarate, Yellow 5, Tocopherol and Less Than 2% Natural Flavour... make Lemonade!

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Help with basic script
« Reply #35 on: May 09, 2010, 09:13:47 pm »
If you want Notepad++ to use two spaces instead of a real tab whenever you press the tab button, do the following:
[...]

I know this doesn't concern me, but thanks! :P
www.soldatx.com.br - The brazilian Soldat community.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #36 on: May 09, 2010, 10:42:36 pm »
@dnmr: well considering i am adding the pas file, dnmr i dont see what the problem is, noone needs to use image recognition software because the physical pas file with the code is there in my posts, you are confusing me dnmr.... unless you are implying that maybe i shuld also post a pastebin URL with my code snapshot instead of attaching the pas file to the post with the snapshot?

@Spilt: Thankyou spilt that will help alot :)

From: May 10, 2010, 01:22:02 am
oh god i have got to be missing something here

Code: (pascal) [Select]
procedure OnMapChange(NewMap: string);
begin
For i := 1 to 32 do
begin
GiveBonus(i, BonusID);
    if GetPlayerStat(i,'Team') = 1 then begin
      Cash:=Cash+GetPlayerStat(i,'Kills');
      WriteConsole(i,'Match Bonus, congrats you have earned your team: '+GetPlayerStat(i,'Kills')+' bonus cash for kills this match',$EE81FAA1);
    end;
end;
end;

i want the Cash to be updated with all the kills last map from each person on alpha team as a bonus but this doesnt launch until the map has actually changed

how do i get it to update the cash just before the time is up and can i set the update to launch when /nextmap is used without causing any conflicts?

wtf once again it hasnt indented correctly and i used your thing to update tabs to 2 spaces spilt
« Last Edit: May 10, 2010, 01:22:56 am by frosty »
check out my server! click here

If at first you don't succeed, Improvise! :D

Offline SpiltCoffee

  • Veteran
  • *****
  • Posts: 1579
  • Spilt, not Split!
    • SpiltCoffee's Site
Re: Help with basic script
« Reply #37 on: May 10, 2010, 03:53:44 am »
Well, in 2.6.5, you'd have to use the AppOnIdle event and check to see if there is a certain amount of time left, and if so, you do your code. Otherwise, if you're using 2.7.0, you can use the OnGameEnd event.
When life hands you High Fructose Corn Syrup, Citric Acid, Ascorbic Acid, Maltodextrin, Sodium Acid Pyrophosphate,
Magnesium Oxide, Calcium Fumarate, Yellow 5, Tocopherol and Less Than 2% Natural Flavour... make Lemonade!

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: Help with basic script
« Reply #38 on: May 10, 2010, 08:54:21 am »
oh god.. you're actually attaching the code as well... That makes the screenshots totally pointless. Nvm.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Help with basic script
« Reply #39 on: May 10, 2010, 01:27:01 pm »
@dnmr: :P lol
check out my server! click here

If at first you don't succeed, Improvise! :D