GTAOnline.net
San Andreas Multiplayer (sa:mp) => Scripting SA-MP [Pawn center] => Discussion démarrée par: ApocKalipsS le 10 Avril 2009, 08:22:25
-
Bonjour, j'ai essayer un petit script qui permet d'enregistrer dansu un fichier le temps qu'il fait.
Voilà mon code :
public timeweather()
{
new weathertime[] = {1,2,3,8,9};
[s]new rand = random(sizeof(weathertime));
SetWeather(weathertime[rand]);
for (new j; j<=MAX_PLAYERS; j++)
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%d", [rand]); //[b] Ligne 592[/b]
new File: filew = fopen("Temps.ini", io_write);
fwrite(filew, coordsstring);
fclose(filew);
}
}
Voilà les erreurs :
C:\Documents and Settings\desktop\Mes documents\Serveur GTA 0.2x\gamemodes\drrp.pwn(11592) : error 029: invalid expression, assumed zero
C:\Documents and Settings\desktop\Mes documents\Serveur GTA 0.2x\gamemodes\drrp.pwn(11592) : warning 215: expression has no effect
C:\Documents and Settings\desktop\Mes documents\Serveur GTA 0.2x\gamemodes\drrp.pwn(11592) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\desktop\Mes documents\Serveur GTA 0.2x\gamemodes\drrp.pwn(11592) : error 029: invalid expression, assumed zero
C:\Documents and Settings\desktop\Mes documents\Serveur GTA 0.2x\gamemodes\drrp.pwn(11592) : fatal error 107: too many error messages on one line
Je n'arrive pas à réglé ce problème, merci de m'aider ![/s]
Woops, j'aurais du réfléchir avant de poster... (Il fallait rajouter 'weathertime' à côté de [rand])
Je n'ai pas encore tester mais si je le fait deux fois il y a deux fois cette action dans le fichier ?
-
Salut,
ton problème provient sans doute de ta façon d'écrire ta variable:
format(coordsstring, sizeof(coordsstring), "%d", [rand]); //[b] Ligne 592[/b]tu ne doit pas mettre les [] dans ce cas...
aussi je te recommanderais de réduire la taille de ton string coordsstring car la longueur maximale qui peut être utiliser est 3 (si l'ion tient compte de toutes les météo), dans le cas ici, 2 (le dernier élément d'un string doit indiquer la fin de ce même string à l'aide de ce caractère '\0' dont la valeur est 0)
Bref, réduit la taille de coordsstring à moins de 6
++Sim++
-
public timeweather()
{
new weathertime[] = {1,2,3,8,9};
new rand = random(sizeof(weathertime));
SetWeather(weathertime[rand]);
for (new j; j<=MAX_PLAYERS; j++)
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%d",rand); //[b] Ligne 592[/b]
new File: filew = fopen("Temps.ini", io_write);
fwrite(filew, coordsstring);
fclose(filew);
}
}essaye ca j ai mis test sur pawno y a pas d erreur mais j ai pas test Ig
-
Voilà mon code :
public timeweather()
{
new weathertime[] = {1,2,3,8,9};
new rand = random(sizeof(weathertime));
for (new j; j<=MAX_PLAYERS; j++)
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%d", weathertime[rand]);
new File: filew = fopen("Temps.ini", io_write);
fwrite(filew, coordsstring);
fclose(filew);
}
}
public PutWeather(playerid)
{
new arrCoords[1][64];
new strFromFile2[256];
new Filewa: filewa = fopen("Temps.ini", io_read);//1601
if (filewa)
{
fread(filewa, strFromFile2);//1604
split(strFromFile2, arrCoords, ',');
SetPlayerWeather(playerid, strval(arrCoords[0]));
fclose(filewa);
}
}
Imaginons que je veux prendre un temps au hasard et que le tmeps s'inscrive dans le fichier. Je le fais, et quand je veux mettre le temps au joueur (PutWeather) ca fait un peu tous beugé... J'apporte plus de précisions plus tard.
Voilà quand même mes erreurs :
:\Documents and Settings\desktop\Mes documents\Serveur GTA 0.2x\gamemodes\drrp.pwn(11601) : warning 213: tag mismatch
C:\Documents and Settings\desktop\Mes documents\Serveur GTA 0.2x\gamemodes\drrp.pwn(11604) : warning 213: tag mismatch
C:\Documents and Settings\desktop\Mes documents\Serveur GTA 0.2x\gamemodes\drrp.pwn(11607) : warning 213: tag mismatch
Comment les régler ?
-
mais pourquoi le mettre dans un fichier tu fait setwaither([rand]);
-
Non je veux le mettre dans un fichier ;).
Donc j'ai plusieurs Tag Mismatch, je sais pas comment les enlever...