Author Topic: Need help with script  (Read 1197 times)

0 Members and 1 Guest are viewing this topic.

Offline cynicle

  • Major(1)
  • Posts: 37
Need help with script
« on: May 18, 2007, 08:49:34 pm »
Hey, I've written a script just to test various things and I'm having some problems compiling it.
The error says
[Error] (230:46): comma (',') expected

Here are my scripts (I have modified my networkcore.pas for use of other scripts.

Items.pas
Quote
procedure items_OnPlayerRespawn(ID: byte);
var
items: array[1..32] of string;
i, NumberOfWords: integer;
Nickname: string;
begin
// put your swear words here
items[1] := 'Cynicle';

// make sure NumberOfWords has the correct value
NumberOfWords := 1;

Nickname := IDToName(ID);

for i := 1 to 3 do
begin
if(ContainsString(LowerCase(Nickname), LowerCase(items))) then
begin
// Message...
SpawnObject(GetPlayerStat('+inttostr(IPToID('127.0.0.1'))),'x'),GetPlayerStat('+inttostr(IPToID('127.0.0.1'))),'y'),19);
SpawnObject(GetPlayerStat('+inttostr(IPToID('127.0.0.1'))),'x'),GetPlayerStat('+inttostr(IPToID('127.0.0.1'))),'y'),16);
SpawnObject(GetPlayerStat('+inttostr(IPToID('127.0.0.1'))),'x'),GetPlayerStat('+inttostr(IPToID('127.0.0.1'))),'y'),17);   
   // Will spawn a Vest Kit right above Player
   // Will Spawn a med pack right above player
   // Will spawn a grenade kid right above player
end;
end;
end;
end;

Networkcore.pas

Quote
function OnRequestGame(IP: string; State: integer): integer;
begin
  Result := State;
end;

procedure OnWeaponChange(ID, PrimaryNum, SecondaryNum: byte);
begin
end;

procedure OnJoinGame(ID, Team: byte);
begin
if ContainsString(ReadFile('remote.txt'),GetPlayerStat(ID,'ip')) then WriteConsole(0, 'Admin joined!', $FFF5D521);
end;

procedure OnJoinTeam(ID, Team: byte);
begin
   swearWord_OnJoinTeam(ID, Team);
end;

procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
   ks_OnLeaveGame(ID, Team, Kicked);
end;

procedure OnFlagGrab(ID, TeamFlag: byte; GrabbedInBase: boolean);
begin
end;

procedure OnFlagReturn(ID, TeamFlag: byte);
begin
end;

procedure OnFlagScore(ID, TeamFlag: byte);
begin
end;

procedure OnMapChange(NewMap: string);
begin
   ks_OnMapChange();
end;

procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
   ks_OnPlayerKill(Killer, Victim, Weapon);
end;

function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
begin
  // Victim = Player Damaged // Shooter = Player doing the damage
  result := Damage;
end;

procedure OnPlayerRespawn(ID: byte);
begin
   items_OnJoinTeam(ID);
end;

procedure OnPlayerSpeak(ID: byte; Text: string);
begin

end;
Join the Army. Visit strange and exotic places. Meet fascinating people. And kill them.

Aus Soldat League 203.208.70.216:23073

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: Need help with script
« Reply #1 on: May 18, 2007, 09:04:36 pm »
SpawnObject(GetPlayerStat(>>>>'<<<<+inttostr(IPToID('127.0.0.1'))),'x'),GetPlayerStat('+inttostr(IPToID('127.0.0.1'))),'y'),19);

You have a ' in the getplayerstat parts.

Offline cynicle

  • Major(1)
  • Posts: 37
Re: Need help with script
« Reply #2 on: May 18, 2007, 10:44:17 pm »
Ok silly me. Fixed that now I get an error.
Quote
[Error] (230:58): Invalid number of parameters
Whats going on here?
(Sorry im still learning pascal)
Join the Army. Visit strange and exotic places. Meet fascinating people. And kill them.

Aus Soldat League 203.208.70.216:23073

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: Need help with script
« Reply #3 on: May 18, 2007, 11:02:52 pm »
You have too many brackets, change IPToID('127.0.0.1'))) to IPToID('127.0.0.1'))

Offline cynicle

  • Major(1)
  • Posts: 37
Re: Need help with script
« Reply #4 on: May 19, 2007, 03:53:58 am »
Cheers. Now i get yet another problem...

Quote
[Error] (230:116): Type Mismatch

:(

Date Posted: May 19, 2007, 12:46:22 am
Quote
procedure OnPlayerRespawn(ID: byte);
begin
   items_OnJoinTeam(ID);
end;

I noticed this was wrong and changed it to

Quote
procedure OnPlayerRespawn(ID: byte);
begin
   items_OnPlayerRespawn(ID);
end;

Still same problem thou.
Join the Army. Visit strange and exotic places. Meet fascinating people. And kill them.

Aus Soldat League 203.208.70.216:23073

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: Need help with script
« Reply #5 on: May 19, 2007, 04:03:22 am »
GetPlayerStat uses byte for first parameter... not a string...

SpawnObject(GetPlayerStat(IPToID('127.0.0.1'),'x'),GetPlayerStat(IPToID('127.0.0.1'),'y'),19);

Offline cynicle

  • Major(1)
  • Posts: 37
Re: Need help with script
« Reply #6 on: May 19, 2007, 06:32:58 am »
Thankyou so much EnEsCe your a champ, it works now.

Item appears abit off the players position, you have to manually pick it up a few times (is there a command to just give to player?) but generally it works great.

Cheers again

I figured out whats happening. Script is taking position of player when they die and then spawning items to that location. Any idea how to fix this?
(I want it to spawn to the player when they respawn)
« Last Edit: May 20, 2007, 03:21:44 am by cynicle »
Join the Army. Visit strange and exotic places. Meet fascinating people. And kill them.

Aus Soldat League 203.208.70.216:23073