Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - Andrechan

#1
Hi!
I've a problem with the function ReadStringback
In my game I keep trace of the six best scores in a file setup.dat.

initialisation in game_start
Code: ags

File* hischandle=File.Open ("setup.dat",eFileRead);

if (hischandle==null) {// file not exists, create one.
Ã,  
hischandle=File.Open ("setup.dat", eFileWrite);Ã,  
int i=0;
while(i<6)
{
Ã,  String str= String.Format("Player %d",i);
hischandle.WriteString(str);
hischandle.WriteInt (0);Ã,  

i++;
} 
}
 
hischandle.Close();

The name of the 6 best players and the scores are initialised to "Player i" and 0.

In the high score room there is this code to read the six scores and put them in six labels of a GUI
Code: ags
int i=0;
String punteggi[6]; //labels with name +point
String giocatore; //temp variable for player
int hiscore; //temp variable for high score
File* hischandle=File.Open ("setup.dat",eFileRead);
while(i<6)
{
Ã,  
Ã,  giocatore=hischandle.ReadStringBack();
Ã,  hiscore=hischandle.ReadInt();
Ã,  punteggi[i]=String.Format("%s: %d",giocatore, hiscore);
Ã,  i++;
Ã,  
 }Ã,  
 
 hischandle.Close();
lblHS1.Text= punteggi[0];
lblHS2.Text= punteggi[1];
lblHS3.Text= punteggi[2];
lblHS4.Text= punteggi[3];
lblHS5.Text= punteggi[4];
lblHS6.Text= punteggi[5];


instead at the end room there is a GUI to insert the name and if you press ok it activates this code
Code: ags

gInsert.Visible=false; //insert name gui
lblName.Text=nameTB.Text;
if(nameTB.Text=="")lblName.Text="Giocatore";
File* hischandle=File.Open ("setup.dat",eFileWrite);

int i=0;
String names[6];
int points[6];

while(i<6)
{
  
  names[i]=hischandle.ReadStringBack();
  points[i]=hischandle.ReadInt();
  i++;
  
 }  
 
//controls if current score is better than one of the high score etc
Ã,  


I run the game and when I enter room 2 and three (2nd and 3rd piece of code) there is an error
"File.ReadStringback : File was not written by WriteString"

But the file IS written by WriteString. ???
What's the problem?
Thanks for your help in advance
#2
Hi!  :)
I would like to let people send their score on a web page (in php). Is it possible to send a Post  Http request to a page?

If it's not possible maybe I can do this way:
After the game over player enters his name and then the game generates an Url of the form
http://myurl/highscore.php?name=John&score=100&code=rrtrgfgd

with the code field a result of cripting the name and the score in some way (to avoid cheating). The php page will control if Cript(name,score)=code
But the problem is: what function can I use to cript?
#3
Hi!
I'm making a classic game where you have to shoot at characters and make points.
This is the code in the repeatedly execute of the room
Code: ags


int i =0;
while(i<=19)
 { 
if((character[i].Room==1) &&(character[i].Moving==0))
{ 

character[i].x= Random(320);
character[i].y= Random(150)+50;

character[i].Walk(character[i].x+ Random(40)-Random(40),character[i].y+ Random(40)-Random(40),eNoBlock,eWalkableAreas);

}

i++;
}

characters appear at a random point of the screen, walk for a while and then disappear.
If you click on one of it then it runs the kill animation, it disappear and the score is updated.
The problem is:
with this code all the 20 characters are on the screen but my idea is that we start with say 5 characters and then they appear more and more with the passage of time. You have to kill them. If there are more than X characters on the screen then you loose.
How can I code it?
Also with my coding if you kill a character then it reappears immediately in another point of the screen so killing is all time wasted  :(

#4
HiÃ,  :)!
I want to make a challenge between characters (a justice speech challenge if you want to knowÃ,  ;D) and I would like to use pretty the same concept of Monkey Island's swordfighting:

After picking a fight with a justice paladin, the main character (Amelia) always has first shot at declaiming.
If the paladin cannot respond, Amelia takes the advantage and gets to pick the next speech (but doesn't learn anything).
If the paladin gives the correct response, the advantage goes to him and he picks the next speech (but Amelia learns the response and has a chance at hearing a new speech).
Whoever gains the advantage three times in the match, wins


The problems I have are:
-The battle can start only if Amelia knows a secret word. After Amelia discovers the word, how can I enable the option with the word in ALL the topics of the paladins?
-I make a topic with all the speech possibles and one with all the answers possibles and at the start they are all off but one. How to recicle these topics for all the paladins? Each paladin has his own set of questions/answers he knows so I need the same topics but different scripts.
If I have to make a copy of the topics for each paladin, how can I turn on a question or an answer in ALL the topics?
-If a paladin gives a correct response, how can I make him pick a random question he knows?
-How can I interrupt the conversation after someone gains the advantage three times?

I hope there are answer to my problems,after playing Monkey Island making a speech challenge is one of my dreamsÃ,  ;D
#5
Hi ! :)
I want to make my character fly to a certain place(hotspot 2) only if the player clicks on it with the pick up
I've made a walkable area (2) in the sky and I've set "change player view while on this area " to the "fly" view.
Then I've inserted this script in the room

// room script file
#sectionstart hotspot2_a  // DO NOT EDIT OR REMOVE THIS LINE
function hotspot2_a() {
  // script for Hotspot 2 (Hotspot 2): Pick up hotspot
RestoreWalkableArea(2); 
}
#sectionend hotspot2_a  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart room_a  // DO NOT EDIT OR REMOVE THIS LINE
function room_a() {
  // script for Room: Player enters room (before fadein)
RemoveWalkableArea(2); 
}
#sectionend room_a  // DO NOT EDIT OR REMOVE THIS LINE

But the walkable area isn't restored if the player picks hotspot2 :-[
What can I do?
SMF spam blocked by CleanTalk