Author Topic: Frosty's scripting thread  (Read 18316 times)

0 Members and 1 Guest are viewing this topic.

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: Frosty's scripting thread
« Reply #80 on: August 07, 2010, 01:36:03 am »
you dont have to send Boolvar[] as an argument since you already send ID. Just declare it as a global array and use as is in the procedure

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Frosty's scripting thread
« Reply #81 on: August 07, 2010, 02:02:08 am »
ok, tx :), but then if i dont send it as an arg, how would i change the boolval [id]? if i use:

Code: (pascal) [Select]
ForceAchUpdate(ID, 'TP', TP);
the Boolval[ID] should change to TP[ID], as Boolval[ID] isnt what i want to change, i only want to update the val thats replacing Boolval, if that makes sense

if i dont send it as an argument, Boolval will stay as Boolval and not turn into the val i want? maybe im doing it wrong? impossible? do i need to recode the procedure?

maybe i need to change it to a function then use result to store the val in a variable then set the var i want to change off that result
« Last Edit: August 07, 2010, 02:15:03 am 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: Frosty's scripting thread
« Reply #82 on: August 07, 2010, 02:27:30 am »
or maybe you should read what i wrote again. Make boolvar a global array so you can interact with it anywhere throughout the script

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Frosty's scripting thread
« Reply #83 on: August 07, 2010, 03:18:21 am »
is this what you mean?:
Code: (pascal) [Select]
var Boolval:Array [1..32] of Boolean;

procedure ForceAchUpdate(ID:Byte; Ach:String); //will update current accounts with new achievements to get as the players join (going to use in OnJoinTeam) 
begin 
if ReadINI('Players/'+IDtoname(ID)+'.ini','achievements',Ach,'*ERROR*') = '*ERROR*' then iniWrite('Players/'+IDtoname(ID)+'.ini','achievements',Ach,'0'); 
     if ReadINI('Players/'+IDtoname(ID)+'.ini','achievements',Ach,'*ERROR while loading achievement*') = '1' then Boolval[ID]:=True;
     if ReadINI('Players/'+IDtoname(ID)+'.ini','achievements',Ach,'*ERROR while loading achievement*') = '0' then Boolval[ID]:=False; 
end; 

procedure OnJoinTeam(ID, Team: byte);
begin
  if (Team = 1) AND (FileExists('Players/'+IDtoname(ID)+'.ini')) then begin
ForceAchUpdate(ID, 'TP');
TP[ID] := Boolval[ID];
end;
end;
« Last Edit: August 07, 2010, 03:29:29 am 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: Frosty's scripting thread
« Reply #84 on: August 07, 2010, 03:55:05 am »
yes, although i cant see what TP is supposed to be, but i guess you're getting the idea

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Frosty's scripting thread
« Reply #85 on: August 07, 2010, 04:08:20 am »
Quote
if ReadINI('Players/'+IDtoname(ID)+'.ini','achievements',Ach,'*ERROR while loading achievement*') = '1' then Boolval[ID]:=True; 
if ReadINI('Players/'+IDtoname(ID)+'.ini','achievements',Ach,'*ERROR while loading achievement*') = '0' then Boolval[ID]:=False;

Boolval[ID] := ReadINI('Players/'+IDtoname(ID)+'.ini','achievements',Ach,'') = '1';

Also you should get a rid of illegal chars from nicknames before naming files with them.
« Last Edit: August 07, 2010, 04:14:30 am by tk »

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Frosty's scripting thread
« Reply #86 on: August 07, 2010, 04:35:51 am »
how do i do that? specially since people wont change their names and it works all off the playername, its not like i can change the players nickname

ive given up on asking ppl to get rid of bad chars, they never do it

and so ive told them:

if your account has bad characters, then your acc will not save, if you like my server, then change your name so it doesnt have the illegal characters

but i guess those ppl dont want accounts being saved, their loss
« Last Edit: August 07, 2010, 04:40:21 am 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: Frosty's scripting thread
« Reply #87 on: August 07, 2010, 05:14:54 am »

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Frosty's scripting thread
« Reply #88 on: August 12, 2010, 01:38:28 am »
tx dnmr :)

trying something with constants, to make it easier to update item prices

in onplayercommand:
Code: (pascal) [Select]
if Lowercase(Text) = '/buy pred' then begin
if Cash < (pred) then begin
WriteConsole(0,IdtoName(ID)+' just tried to purchase predator, not enough funds!',$EE81FAA1);
end;
if Cash >= (pred) then begin
Cash :=Cash-(pred);
WriteConsole(0,IdtoName(ID)+' has just bought predator for '+(pred)+' Cash',$EE81FAA1);
GiveBonus(ID, 1);
SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),20);
      TUPred[ID]:=TUPred[ID]+1;
end;
  end;

pred is defined as a const, how do i use the const in this example?

arsse is giving me the following error
Code: [Select]
open round ('(')expected
to attempt a debug i tried putting ()s on each side of pred in the code, but the same error remains, i know its definitely the "pred" const causing the error, as the error only occured when i (tried to) put the const in there

Code: (pascal) [Select]
const
pred = 200;

having inttostr in writeconsole for pred does nothing for the error, what do i need to show the consts value in writeconsole if i can get the code to work?
« Last Edit: August 12, 2010, 01:42:46 am by frosty »
check out my server! click here

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

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Frosty's scripting thread
« Reply #89 on: August 12, 2010, 02:46:57 am »
Since you declare the const as int, you have to convert it into a string before doing anything with it in writeconsole
WriteConsole(0,IdtoName(ID)+' has just bought predator for '+IntToStr(pred)+' Cash',$EE81FAA1);

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Frosty's scripting thread
« Reply #90 on: August 12, 2010, 04:19:31 am »
yes but whats causing the error?

even if i do have inttostr there the error is still there

Code: (pascal) [Select]
if Lowercase(Text) = '/buy pred' then begin 
    if Cash < (pred) then begin 
        WriteConsole(0,IdtoName(ID)+' just tried to purchase predator, not enough funds!',$EE81FAA1); 
    end;   
    if Cash >= (pred) then begin 
        Cash :=Cash-(pred); 
        WriteConsole(0,IdtoName(ID)+' has just bought predator for '+IntToStr(pred)+' Cash',$EE81FAA1);
        GiveBonus(ID, 1); 
        SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),20); 
     TUPred[ID]:=TUPred[ID]+1; 
    end; 
 end; 
check out my server! click here

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

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: Frosty's scripting thread
« Reply #91 on: August 12, 2010, 04:33:59 am »
is the scriptcore giving you an error, or just arsse?
Error doesn't seem like something the scriptcore would chuck out, but then again, I don't know much about arsse.
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Frosty's scripting thread
« Reply #92 on: August 12, 2010, 01:12:02 pm »
scriptcore is giving me the exact same error

Code: (pascal) [Select]
if Lowercase(Text) = '/buy pred' then begin   
   if Cash < (pred) then begin //actuall error is on this line, why isnt pred being parsed correctly? error doesnt point directly to this line, points above it, however after counting commented out lines (section it was pointing to was not changed, neither was anything above it, except for consts, and there were 15 commented out lines before that line) and adding the result number to the supposed error line (387+15=line 402)
       WriteConsole(0,IdtoName(ID)+' just tried to purchase predator, not enough funds!',$EE81FAA1);   
   end;     
   if Cash >= (pred) then begin   
       Cash :=Cash-(pred);   
       WriteConsole(0,IdtoName(ID)+' has just bought predator for '+IntToStr(pred)+' Cash',$EE81FAA1); 
       GiveBonus(ID, 1);   
       SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),20);   
    TUPred[ID]:=TUPred[ID]+1;   
   end;   
end;


full code is attached

i have also included the original shop.pas (named Shop_original.pas)

so you can see what changes ive made

btw, just to clear this up, when you /recompile with arsse, it isnt actually arsse thats compiling the scripts, its the servers scriptore that its connected to that is, arsse doesnt have or use a compiler, all it does is relay commands to the server and output server messages, thats it :D
« Last Edit: August 12, 2010, 01:35:06 pm by frosty »
check out my server! click here

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

Offline Falcon`

  • Flagrunner
  • ****
  • Posts: 792
  • A wanted lagger
Re: Frosty's scripting thread
« Reply #93 on: August 12, 2010, 07:45:44 pm »
remove parenthesis
If you're not paying for something, you're not the customer; you're the product being sold.
- Andrew Lewis

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Frosty's scripting thread
« Reply #94 on: August 13, 2010, 12:31:49 am »
got rid of the ( ) s but the error is still the same

see pastebin link

http://pastebin.com/bG6dckm0

edit: how do i create a bullet going from mone player to another again?, i know one of you guys posted it somewhere but i cant find, could u plz post it again? :D, i know it was something about the sin, cos and tan things..
« Last Edit: August 13, 2010, 02:09:54 am by frosty »
check out my server! click here

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

Offline kosik231

  • Major
  • *
  • Posts: 70
  • Where can I find Your soul?
Re: Frosty's scripting thread
« Reply #95 on: August 13, 2010, 06:57:49 am »
i found mistake :D change const name "pred" to another one like "predat", i think that script used your "/buy pred" as variable O.o btw it works for me
For signatures, you are allowed only one image in your signature which may not be wider and taller than 300 and 125 pixels, and may not be over 20kB in file size. No BMPs are allowed.

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Frosty's scripting thread
« Reply #96 on: August 13, 2010, 07:11:37 am »
LOL, its an emote, most people use that instead of "Doh!"

and thanks :D, it worked :D, changing pred to predat fixed the problem, many thanks
« Last Edit: August 13, 2010, 07:14:59 am 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: Frosty's scripting thread
« Reply #97 on: August 13, 2010, 07:25:23 am »
go through the mmod script, it should have the shooting function you need, as well as a bunch of other stuff

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Frosty's scripting thread
« Reply #98 on: August 13, 2010, 09:21:16 am »
Quote
edit: how do i create a bullet going from mone player to another again?, i know one of you guys posted it somewhere but i cant find, could u plz post it again? , i know it was something about the sin, cos and tan things..
You don't have to use neither of them

procedure Shoot(x, y, x2, y2, speed, dmg: single; style, owner: byte);
var dist: single;
begin
 dist := Distance(x, y, x2, y2) / speed;
 x2 := (x2 - x) / dist;
 y2 := (y2 - y) / dist;
 createbullet(x, y, x2, y2, dmg, style, owner);
end;
 
(untested)
 
« Last Edit: August 14, 2010, 02:21:01 am by tk »

Offline frosty

  • Flagrunner
  • ****
  • Posts: 601
  • Uber Desert Eagle ^^
Re: Frosty's scripting thread
« Reply #99 on: August 13, 2010, 08:20:55 pm »
@tk, that gives me a type mismatch error on line 6 of that code, cant see why tho, ill have a look at mmod, tx dnmr ;)

From: August 13, 2010, 08:22:03 pm
check out my server! click here

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