Author Topic: help with script  (Read 1056 times)

0 Members and 1 Guest are viewing this topic.

Offline kuposrock

  • Major(1)
  • Posts: 33
  • iz are the muffin man
help with script
« on: November 29, 2008, 08:11:35 pm »
ok i kinda know how to script now but i have a problem with it. I made a scirpt where when a person says /turret a turret spawns on him. but the problem is it doesnt do it for the person saying turret, it does it for player 1 can some one help? heres my code:

function OnPlayerCommand(ID: Byte; Text: string): boolean;
var x,y: single;
begin
    if Text = '/turret' then begin
    SpawnObject(GetPlayerStat(1,'x'),GetPlayerStat(1,'y'),15);
   end;
end;


and how do u put code in a box?
[signature removed; please read forum rules]

Offline SpiltCoffee

  • Veteran
  • *****
  • Posts: 1579
  • Spilt, not Split!
    • SpiltCoffee's Site
Re: help with script
« Reply #1 on: November 29, 2008, 08:19:25 pm »
It'll be because of this line.

Code: [Select]
SpawnObject(GetPlayerStat(1,'x'),GetPlayerStat(1,'y'),15);

Try replacing it with this.

Code: [Select]
SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),15);

Instead of using 1, use ID. :D

Oh, and to put code into a box, use the [code] tag.
« Last Edit: November 29, 2008, 08:21:54 pm by SpiltCoffee »
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 kuposrock

  • Major(1)
  • Posts: 33
  • iz are the muffin man
Re: help with script
« Reply #2 on: November 29, 2008, 08:30:52 pm »
It'll be because of this line.

Code: [Select]
SpawnObject(GetPlayerStat(1,'x'),GetPlayerStat(1,'y'),15);

Try replacing it with this.

Code: [Select]
SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),15);

Instead of using 1, use ID. :D

Oh, and to put code into a box, use the [code] tag.

ok thx :)
[signature removed; please read forum rules]

Offline kuposrock

  • Major(1)
  • Posts: 33
  • iz are the muffin man
Re: help with script
« Reply #3 on: November 29, 2008, 09:45:28 pm »
i have another question. and sorry for the double post, id rather double post then start a hole new section just for 1 question.
How do u make the console say something.
like
if Text = '/help'  then the console would comment what i put in.
[signature removed; please read forum rules]

Offline SpiltCoffee

  • Veteran
  • *****
  • Posts: 1579
  • Spilt, not Split!
    • SpiltCoffee's Site
Re: help with script
« Reply #4 on: November 29, 2008, 11:46:05 pm »
Use WriteConsole(ID,Text,Color) or SayToPlayer(ID,Text).

Check the Scripting Manual for info on those functions.
though by the looks of things, you've already found the manual.
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 kuposrock

  • Major(1)
  • Posts: 33
  • iz are the muffin man
Re: help with script
« Reply #5 on: November 30, 2008, 01:14:25 am »
k thanks i could find the writeconsole thing lol
[signature removed; please read forum rules]