Author Topic: Urgent Problem, needs fixing ASAP  (Read 9252 times)

0 Members and 1 Guest are viewing this topic.

Offline SpiltCoffee

  • Veteran
  • *****
  • Posts: 1579
  • Spilt, not Split!
    • SpiltCoffee's Site
Re: Urgent Problem, needs fixing ASAP
« Reply #40 on: April 15, 2010, 03:35:51 am »
As mentioned earlier, HighestID is only implemented in the 2.7.0 ScriptCore. In the 2.6.5 ScriptCore, you will have to use something else instead (like 32).
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: Urgent Problem, needs fixing ASAP
« Reply #41 on: April 15, 2010, 04:58:21 am »
or make a custom function which calculates HighestID for you. You'll need to use it on player join/leave and on adding bots

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Urgent Problem, needs fixing ASAP
« Reply #42 on: April 15, 2010, 01:20:09 pm »
or make a custom function which calculates HighestID for you. You'll need to use it on player join/leave and on adding bots

custom function not needed

all i really need is this, after defining HighestID as a variable:
Code: (pascal) [Select]
HighestID:=Numplayers+Numbots;

i think this would be better than just NumPlayers, although Numplayers is counting Bots also, Numplayers isnt just counting players its counting bots also

i had to do this in one of my scripts just to get the number of JUST players, this was done during a debug, now the script for it works perfect, without this line and PlayersActive being Numplayers that script is then a junk heap ><:
Code: (pascal) [Select]
PlayersActive := NumPlayers - Numbots
see? i had to subtract the number of bots from the number of players to get the ACTUAL number of players, else what i had set as an if would fail completely, thus, me saying: Numplayers ISNT just counting players its counting bots also

dnmr, was it you who said Numplayers was counting players only? :P

in case ur wondering this is what i found out during my debug:
http://pastebin.com/8kfbG17R
check out my server! click here

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

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Urgent Problem, needs fixing ASAP
« Reply #43 on: April 15, 2010, 02:08:31 pm »
You can't use NumPlayers either NumBots in either way to calculate the highest ID. Maybe there is a player with ID 20, and 12 humans or bots are on the server.
Anyway, that's the best & easiest way:
Code: (pascal) [Select]
function HighestID: byte;
begin
  for Result := 32 downto 1 do
    if GetPlayerStat(Result, 'Active') = true then
      break;
end;

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Urgent Problem, needs fixing ASAP
« Reply #44 on: April 15, 2010, 03:32:10 pm »
Just do to 32, it is the easiest, and unless you have many many nested loops, it isn't going to be an issue when it comes to performance. And its easier to be sure the code is correct too. At least that's my opinion.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Urgent Problem, needs fixing ASAP
« Reply #45 on: April 16, 2010, 02:26:46 am »
well if i do use 32, then if it comes across a number that doesn't match an id the script tends to "crash"

dunno why

ur code will prolly work better swompie :D
« Last Edit: April 16, 2010, 02:51:45 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: Urgent Problem, needs fixing ASAP
« Reply #46 on: April 16, 2010, 03:03:42 am »
If your code is crashing with 1 to 32, you're doing something wrong in your script. Using another number there is not the way to fix this problem.
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: Urgent Problem, needs fixing ASAP
« Reply #47 on: April 16, 2010, 08:35:46 am »
always check if the player is active before doing something with him, and you shouldnt have any problems

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Urgent Problem, needs fixing ASAP
« Reply #48 on: April 16, 2010, 05:39:57 pm »
Code: (pascal) [Select]
Function Setteam(ID,Team:Byte):String;
begin
Command('/setteam'+Floattostr(Team)+' '+Floattostr(ID));
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
if Text = '/red' then
begin
   Setteam(ID,1);
end;
end;

Quote
[8:11] syntax error

what????
« Last Edit: April 16, 2010, 05:52:42 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: Urgent Problem, needs fixing ASAP
« Reply #49 on: April 16, 2010, 05:48:50 pm »
[...]
what????

Try this one.

Code: (pascal) [Select]
Procedure SetTeam(ID, Team: Byte);
 Begin
  Command('/setteam'+IntToStr(Team)+' '+IntToStr(ID));
end;

You don't need to use FloatToStr(). It's an Integer value, not a Float one ;)

Although, I don't see the point at making this Procedure. It's just a line, ffs. Go Command() instead.

Well, I would. It's your choice.
« Last Edit: April 16, 2010, 05:50:43 pm by squiddy »
www.soldatx.com.br - The brazilian Soldat community.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Urgent Problem, needs fixing ASAP
« Reply #50 on: April 16, 2010, 05:54:35 pm »
Edit above

thanks tho squiddy

tho if i use Command it errors with numbers if its in the script that why i have to use a function

but now why am i getting a syntax error?

From: April 16, 2010, 05:56:30 pm
nvm soon as i added ur code it stopped erroring

From: April 16, 2010, 06:01:56 pm
actually no

Code: (pascal) [Select]
Procedure SetTeam(ID, Team: Byte);
begin
  Command('/setteam'+IntToStr(Team)+' '+IntToStr(ID));
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
if Text = '/red' then
begin
   Setteam(ID,1);
end;

if Text = '/spec' then
begin
   Setteam(ID,5);
end;
end;

function OnCommand(ID: Byte; Text: string): boolean;
begin
if Text = '/blue' then
begin
   Setteam(ID,2);
end;

if Text = '/green' then
begin
   Setteam(ID,3);
end;

if Text = '/yellow' then
begin
   Setteam(ID,4);
end;
end;

1:34 colon expected

or i get unexpected end of file (3:32)
« Last Edit: April 16, 2010, 06:01:56 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: Urgent Problem, needs fixing ASAP
« Reply #51 on: April 16, 2010, 06:02:56 pm »
[...]
tho if i use Command it errors with numbers if its in the script that why i have to use a function
[...]

I believe you meant that when you use Command() it crashes ?

Well, just go "Command('/setteam5 '+IntToStr(ID));", to change player ID to spectators.

Your welcome for the code. ;)

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: Urgent Problem, needs fixing ASAP
« Reply #52 on: April 17, 2010, 01:03:55 am »
Code: (pascal) [Select]
var
Cash,DEC,DECC,Botn,EBNN,EBNND,EBNNT,EDMM,EDMMT,EDMMD:Integer;
BonusID,ID,EBN,EBNM,ED,EDM,DED,i:Byte;
Command:String;
deathexp,HC: Boolean;

function HighestID: byte;
begin
  for Result := 32 downto 1 do
    if GetPlayerStat(Result, 'Active') = true then
      break;
end;
Quote
[9:2] unexpected end of file
[9:2] syntax error
darn it >=(
« Last Edit: April 17, 2010, 01:24:15 am by frosty »
check out my server! click here

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

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Urgent Problem, needs fixing ASAP
« Reply #53 on: April 17, 2010, 02:41:32 am »
Did you try to start the server without HighestID code? Can't see any fails currently. Wther semicolon fails or such a thing, I've always got that error when I had an ยด or ` somewhere in the script placed out of a type mistake.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Urgent Problem, needs fixing ASAP
« Reply #54 on: April 17, 2010, 03:03:13 am »
it only failed when i added the HighestID Code, yes i did try to start the server just before adding


but as soon as i comment it out it works fine so wtf

and i dont see any sytax errors, all working if statements that have a true or false answer are exact
« Last Edit: April 17, 2010, 03:07:16 am 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: Urgent Problem, needs fixing ASAP
« Reply #55 on: April 17, 2010, 05:09:08 am »
Try this:

Code: (pascal) [Select]
Function HighestID(): Byte;
 Var Dude: Byte;
  Begin
  For Dude := 32 DownTo 1 Do if GetPlayerStat(Dude,'Active') = True Then Break;
 Result := Dude;
end;

Always when you get such an errorr like that, write it all over again, with different Vars. Might help.
www.soldatx.com.br - The brazilian Soldat community.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Urgent Problem, needs fixing ASAP
« Reply #56 on: April 17, 2010, 05:50:26 am »
[2:2]syntax error
[2:2]begin expected

and if i move the var to the global vars i get this:

[3:2]syntax error
[3:2]unexpected end of file

which points to line 4 on your code since line 3 was moved and line 4 became line 3
« Last Edit: April 17, 2010, 05:52:27 am by frosty »
check out my server! click here

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

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Urgent Problem, needs fixing ASAP
« Reply #57 on: April 17, 2010, 06:05:52 am »
Can you post the whole code with HighestID, you don't have to :P (In normal code tags or attach w/e you like)
Maybe we can find the error, sth. must cause it since HighestID definetily isn't.
You use the server version 265?

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Urgent Problem, needs fixing ASAP
« Reply #58 on: April 17, 2010, 06:23:53 am »
it cant be because if thats the case even with HighestID uncommented it wont compile

it ONLY compiles if HightestID is COMMENTED OUT, at the moment its working perfect, ONLY because i have HighestID commented out, anyways heres the full script:

http://pastebin.com/hwRnkARG

it IS compiling but WILL NOT compile with HighestID uncommented

and yes i do believe that the server host is using 265
« Last Edit: April 17, 2010, 06:26:04 am by frosty »
check out my server! click here

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

Offline Swompie

  • Camper
  • ***
  • Posts: 390
Re: Urgent Problem, needs fixing ASAP
« Reply #59 on: April 17, 2010, 06:44:40 am »
Any other scripts? For me it just compiles fine..