Author Topic: Request: SpawnToPlayerObjectScript  (Read 1645 times)

0 Members and 1 Guest are viewing this topic.

Offline BurnedKirby

  • Major(1)
  • Posts: 39
Request: SpawnToPlayerObjectScript
« on: September 24, 2007, 09:05:27 pm »
What I'm trying to make is a script where a admin can type "/spwng 15" and that would spawn gernades at player number 15. I'm not that good at scripting yet, but I do know it is a OnCommand function, and I could do the text part and spawn object myself, but I'm not sure how to implement the player number to specifically spawn the object to that player. I'm not even sure if I have to initialize a variable to be set to that integer. So, yeah, just a simple object spawning request to spawn something to anyplayer. All I need is the basic format.

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: Request: SpawnToPlayerObjectScript
« Reply #1 on: September 24, 2007, 09:19:10 pm »
Functions aren't going to be added just because you don't know how to code it yourself...

Offline Aquarius

  • Soldier
  • **
  • Posts: 234
Re: Request: SpawnToPlayerObjectScript
« Reply #2 on: September 25, 2007, 12:47:52 am »
Use GetPlayerStat( num, 'X' ) and GetPlayerStat( num, 'Y' ) to get player coordinates. num should be the player number ("15" part from "/spwng 15" ). To get player number you have to split the command and convert it to byte:
num := StrToByte( GetPiece(Text,' ',2) );

I didn't test it but it should work. Just remember to declare the num variable first.

Offline BurnedKirby

  • Major(1)
  • Posts: 39
Re: Request: SpawnToPlayerObjectScript
« Reply #3 on: September 25, 2007, 07:02:18 pm »
Functions aren't going to be added just because you don't know how to code it yourself...

Maybe I didn't make myself clear. I would like for someone to explain to me how to take a number entered by a admin via command and take that number to be used further in the script.

Date Posted: September 25, 2007, 05:35:53 pm
All I want to do, is to take the number given by the admin, and apply that number to an integer. Thats all I need to know.

Date Posted: September 25, 2007, 05:40:39 pm
You know what? since none of you don't even want to help, someone please delete this topic. If no one reads this anyway, I guess it will be buried by other topics. Ill figure it out. eventually...

In case anyone would want to read this, I have tried to come up with a code, but it doesn't work despite the fact that it has no errors. Help?

function OnCommand(ID: Byte;Text: string):boolean;
begin
Result:=false;
if GetPiece(LowerCase(Text),'',0)='/spwnh' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),'',1)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),'',1)),'y'),16);
end;
if GetPiece(LowerCase(Text),'',0)='/spwng' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),'',1)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),'',1)),'y'),17);
end;
if GetPiece(LowerCase(Text),'',0)='/spwnf' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),'',1)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),'',1)),'y'),18);
end;
if GetPiece(LowerCase(Text),'',0)='/spwnv' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),'',1)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),'',1)),'y'),19);
end;
if GetPiece(LowerCase(Text),'',0)='/spwnp' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),'',1)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),'',1)),'y'),20);
end;
if GetPiece(LowerCase(Text),'',0)='/spwnb' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),'',1)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),'',1)),'y'),21);
end;
if GetPiece(LowerCase(Text),'',0)='/spwnc' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),'',1)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),'',1)),'y'),22);
end;
end;
« Last Edit: September 25, 2007, 07:37:54 pm by BurnedKirby »

Offline Aquarius

  • Soldier
  • **
  • Posts: 234
Re: Request: SpawnToPlayerObjectScript
« Reply #4 on: September 25, 2007, 08:58:59 pm »
I think second parameter in GetPiece should be ' ' (space character) not ''  and third parameter should be 1 and 2 not 0 and 1. Again, I didn't test it but that's what I noticed in your code at a first glance.
« Last Edit: September 25, 2007, 09:05:48 pm by Aquarius »

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: Request: SpawnToPlayerObjectScript
« Reply #5 on: September 26, 2007, 03:43:47 pm »
I already made these, but they're a little complex

(/create [pnum] [xoff] [yoff] [xvel] [yvel] [hitm] [owns])
(/spawn [onum] [pnum])
(/force [pnum] [prim] [secd] [ammo])
(/mega [script] ***params***)

heh... I could simplify tho
and you can't have them :P I might release them when I feel like it (most of these I got help from Toumaz to do, you could ask him)
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline BurnedKirby

  • Major(1)
  • Posts: 39
Re: Request: SpawnToPlayerObjectScript
« Reply #6 on: September 26, 2007, 04:27:43 pm »
Thanks for the help Aquarius, but it still isn't working for me. Does it matter if the player number is double digits? because I'm only using double digits for the player number.

Kavukamari, it would be greatly appreciated if you did release that script, but its up to you. If you want to keep it for yourself, its fine. I'll just learn more at scripting.


This is my edited script so far...

function OnCommand(ID: Byte;Text: string):boolean;
begin
Result:=false;
if GetPiece(LowerCase(Text),' ',1)='/spwnh' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'y'),16);
end;
if GetPiece(LowerCase(Text),' ',1)='/spwng' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'y'),17);
end;
if GetPiece(LowerCase(Text),' ',1)='/spwnf' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'y'),18);
end;
if GetPiece(LowerCase(Text),' ',1)='/spwnv' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'y'),19);
end;
if GetPiece(LowerCase(Text),' ',1)='/spwnp' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'y'),20);
end;
if GetPiece(LowerCase(Text),' ',1)='/spwnb' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'y'),21);
end;
if GetPiece(LowerCase(Text),' ',1)='/spwnc' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'y'),22);
end;
end;

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Request: SpawnToPlayerObjectScript
« Reply #7 on: September 26, 2007, 04:50:10 pm »
Thanks for the help Aquarius, but it still isn't working for me. Does it matter if the player number is double digits? because I'm only using double digits for the player number.

Kavukamari, it would be greatly appreciated if you did release that script, but its up to you. If you want to keep it for yourself, its fine. I'll just learn more at scripting.


This is my edited script so far...

function OnCommand(ID: Byte;Text: string):boolean;
begin
Result:=false;
if GetPiece(LowerCase(Text),' ',1)='/spwnh' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'y'),16);
end;
if GetPiece(LowerCase(Text),' ',1)='/spwng' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'y'),17);
end;
if GetPiece(LowerCase(Text),' ',1)='/spwnf' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'y'),18);
end;
if GetPiece(LowerCase(Text),' ',1)='/spwnv' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'y'),19);
end;
if GetPiece(LowerCase(Text),' ',1)='/spwnp' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'y'),20);
end;
if GetPiece(LowerCase(Text),' ',1)='/spwnb' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'y'),21);
end;
if GetPiece(LowerCase(Text),' ',1)='/spwnc' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),' ',2)),'y'),22);
end;
end;
one thing wrong is with GetPiece, the third # is 1 more than it should be...
GetPiece('this good food',' ',0) = 'this'
GetPiece('this good food',' ',1) = 'good'
GetPiece('this good food',' ',2) = 'food'

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: Request: SpawnToPlayerObjectScript
« Reply #8 on: September 26, 2007, 05:44:59 pm »
wutever, I'll post it when I get home

it's part of a bigger script, so it might take a while (and you'll be lucky if I even go on the computer (cause of Halo 3)) I'm at school right now :(

I might just code a special something just for you, so you don't have to memorise constants and stuff
(I might code a "if piece2 = *part of weapon/pak name* then do wutever"... thing)
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline BurnedKirby

  • Major(1)
  • Posts: 39
Re: Request: SpawnToPlayerObjectScript
« Reply #9 on: September 26, 2007, 06:32:35 pm »
Thank you Kavukamari, but you don't really have to. And thank you DorkeyDear for getting rid of my problem.

for anyone who wants the finished script, here it is:

function OnCommand(ID: Byte;Text: string):boolean;
begin
Result:=false;
if GetPiece(LowerCase(Text),' ',0)='/spwnh' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),' ',1)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),' ',1)),'y'),16);
end;
if GetPiece(LowerCase(Text),' ',0)='/spwng' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),' ',1)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),' ',1)),'y'),17);
end;
if GetPiece(LowerCase(Text),' ',0)='/spwnf' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),' ',1)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),' ',1)),'y'),18);
end;
if GetPiece(LowerCase(Text),' ',0)='/spwnv' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),' ',1)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),' ',1)),'y'),19);
end;
if GetPiece(LowerCase(Text),' ',0)='/spwnp' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),' ',1)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),' ',1)),'y'),20);
end;
if GetPiece(LowerCase(Text),' ',0)='/spwnb' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),' ',1)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),' ',1)),'y'),21);
end;
if GetPiece(LowerCase(Text),' ',0)='/spwnc' then begin
SpawnObject(GetPlayerStat(StrtoInt(GetPiece((Text),' ',1)),'x'),GetPlayerStat(StrtoInt(GetPiece((Text),' ',1)),'y'),22);
end;
end;

Offline Unknown_member

  • Major(1)
  • Posts: 4
Re: Request: SpawnToPlayerObjectScript
« Reply #10 on: October 04, 2007, 07:57:17 pm »
Hi all
I'm new here and just wanted  post the same Topic.
Ive some experience in programming and i could write a much shorter one....

here is it

function OnCommand(ID: Byte; Text: string): boolean;
begin
if GetPiece(LowerCase(Text),' ',0)='/give' then begin
SpawnObject(GetPlayerStat(strtoint(GetPiece(Text, ' ', 1)),'x'),GetPlayerStat(strtoint(GetPiece(Text, ' ', 1)),'y'),strtoint(GetPiece(Text, ' ', 2)));
end;
end;



ps if some1 find orthografical misstakes, he can keep it ;P

pps have i open a new topic in  Scripting relesses or willl it be moved?
« Last Edit: October 04, 2007, 08:06:40 pm by Unknown_member »
Mess with the Best, Die like the Rest !

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Request: SpawnToPlayerObjectScript
« Reply #11 on: October 04, 2007, 08:10:09 pm »
Hi all
I'm new here and just wanted  post the same Topic.
Ive some experience in programming and i could write a much shorter one....

here is it

function OnCommand(ID: Byte; Text: string): boolean;
begin
if GetPiece(LowerCase(Text),' ',0)='/give' then begin
SpawnObject(GetPlayerStat(strtoint(GetPiece(Text, ' ', 1)),'x'),GetPlayerStat(strtoint(GetPiece(Text, ' ', 1)),'y'),strtoint(GetPiece(Text, ' ', 2)));
end;
end;



ps if some1 find orthografical misstakes, he can keep it ;P


First thing I saw was the "if (Text = '/give ')", it should be "if (GetPiece(Text,' ',0) = '/give')"
And all ur other getpieces 3rd parameters should be 1 less... the thingy starts at 0..
GetPiece('this is a test',' ',0) = 'this'
GetPiece('this is a test',' ',1) = 'is'
GetPiece('this is a test',' ',2) = 'a'
GetPiece('this is a test',' ',3) = 'test'

also the thing should be inside a "try" so that if the inpurted player id is not an integer, it doesn't bring up an error..

try
  SpawnObject(...);
except
  //stuff that happens if an error comes up; error doesn't actually come up
end;

Offline Unknown_member

  • Major(1)
  • Posts: 4
Re: Request: SpawnToPlayerObjectScript
« Reply #12 on: October 04, 2007, 08:27:17 pm »
thanks for replay dear donkey ;P

you re right it brings an error if an misstake is written...
so you mean it should be

function OnCommand(ID: Byte; Text: string): boolean;
begin
if GetPiece(LowerCase(Text),' ',0)='/give' then begin
try
SpawnObject(GetPlayerStat(strtoint(GetPiece(Text, ' ', 1)),'x'),GetPlayerStat(strtoint(GetPiece(Text, ' ', 1)),'y'),strtoint(GetPiece(Text, ' ', 2)));
end;
end;
end;

the funniest thing is that ´bout 20Min's ago i my script didn't worked and i wanted to post it in this forum to find a solution but while modifying my post i found my misstake ;P

ok g2sleep 3hours left befor i wake up to school (germany) ;P
Mess with the Best, Die like the Rest !