Jump to content

Cum adaugam masinile din scriptfiles pe server


~Hunt3r~

Recommended Posts

Deci banuiesc ca multi dintre voi ati intrat in  ,,scriptfiles'' si  acolo atzi gasit un folder de genu'  ,,vehiclelists'' .Daca ati intrat in acele fisiere  notepad de ex: ,,red_county.txt'' ati gasit niste coordonate fara  ,,AddStaticVehicle'' inclus sau altceva

Acele coordonate sunt ale masinilor din jok puse intr-o ordine (ca la SinglePlayer)

Pt a pune acele vehicule pe server fara a mai adauga  ,,AddStaticVehicle'' sau altceva  faceti urmatoarele:

1.  Deschideti GM vostru

2.  Cautati 

public OnGameModeInit()
Si adaugati acolo :
new total_vehicles_from_files=0;

total_vehicles_from_files += LoadStaticVehiclesFromFile("vehiclelists/red_county.txt");
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehiclelists/lv_gen.txt");
Aici puteti adauga mai multe vehicule din folder-ul vehiclelists , eu am adaugat doar 2 exemple .Deci pt a baga si altele cu ar fi  ,, whetstone.txt '' schimbati de ex:
red_county.txt
din cod-ul de mai sus cu
whetstone.txt
si va iesi asa:
total_vehicles_from_files += LoadStaticVehiclesFromFile("vehiclelists/whetstone.txt");
Iar dupa aceia punem dupa
public OnGameModeExit()
{
   	return 1;
}
Asta:
LoadStaticVehiclesFromFile(const filename[])
{
	new File:file_ptr;
	new line[256];
	new var_from_line[64];
	new vehicletype;
	new Float:SpawnX;
	new Float:SpawnY;
	new Float:SpawnZ;
	new Float:SpawnRot;
	new Color1, Color2;
	new index;
	new vehicles_loaded;

	file_ptr = fopen(filename,filemode:io_read);
	if(!file_ptr) return 0;

	vehicles_loaded = 0;

	while(fread(file_ptr,line,256) > 0)
	{
	    index = 0;

	    // Read tip
  		index = token_by_delim(line,var_from_line,',',index);
  		if(index == (-1)) continue;
  		vehicletype = strval(var_from_line);
   		if(vehicletype < 400 || vehicletype > 611) continue;

  		// Read X, Y, Z, Rotation
  		index = token_by_delim(line,var_from_line,',',index+1);
  		if(index == (-1)) continue;
  		SpawnX = floatstr(var_from_line);

  		index = token_by_delim(line,var_from_line,',',index+1);
  		if(index == (-1)) continue;
  		SpawnY = floatstr(var_from_line);

  		index = token_by_delim(line,var_from_line,',',index+1);
  		if(index == (-1)) continue;
  		SpawnZ = floatstr(var_from_line);

  		index = token_by_delim(line,var_from_line,',',index+1);
  		if(index == (-1)) continue;
  		SpawnRot = floatstr(var_from_line);

  		// Read Color1, Color2
  		index = token_by_delim(line,var_from_line,',',index+1);
  		if(index == (-1)) continue;
  		Color1 = strval(var_from_line);

  		index = token_by_delim(line,var_from_line,';',index+1);
  		Color2 = strval(var_from_line);

  		//printf("%d|%f|%f|%f|%f|%d|%d",vehicletype,
  		    //SpawnX,SpawnY,SpawnZ,SpawnRot,Color1,Color2);

		AddStaticVehicleEx(vehicletype,SpawnX,SpawnY,SpawnZ,SpawnRot,Color1,Color2,-1);

		vehicles_loaded++;
	}

	fclose(file_ptr);
	printf("Loaded %d vehicles from: %s",vehicles_loaded,filename);
	return vehicles_loaded;
}
//--------------------------------------------------------------------------------------------

token_by_delim(const string[], return_str[], delim, start_index)
{
	new x=0;
	while(string[start_index] != EOS && string[start_index] != delim) {
	    return_str[x] = string[start_index];
	    x++;
	    start_index++;
	}
	return_str[x] = EOS;
	if(string[start_index] == EOS) start_index = (-1);
	return start_index;
}
Si teoretic va trebui sa va apara masinile joc . Mai complet ar trebui sa a iasa asa:
public OnGameModeInit()
{
//NewCars
    new total_vehicles_from_files=0;
    
    total_vehicles_from_files += LoadStaticVehiclesFromFile("vehiclelists/lv_gen.txt");
    total_vehicles_from_files += LoadStaticVehiclesFromFile("vehiclelists/bone.txt");
    total_vehicles_from_files += LoadStaticVehiclesFromFile("vehiclelists/sf_airport.txt");
}
public OnGameModeExit()
{
   	return 1;
}
LoadStaticVehiclesFromFile(const filename[])
{
	new File:file_ptr;
	new line[256];
	new var_from_line[64];
	new vehicletype;
	new Float:SpawnX;
	new Float:SpawnY;
	new Float:SpawnZ;
	new Float:SpawnRot;
	new Color1, Color2;
	new index;
	new vehicles_loaded;

	file_ptr = fopen(filename,filemode:io_read);
	if(!file_ptr) return 0;

	vehicles_loaded = 0;

	while(fread(file_ptr,line,256) > 0)
	{
	    index = 0;

	    // Read type
  		index = token_by_delim(line,var_from_line,',',index);
  		if(index == (-1)) continue;
  		vehicletype = strval(var_from_line);
   		if(vehicletype < 400 || vehicletype > 611) continue;

  		// Read X, Y, Z, Rotation
  		index = token_by_delim(line,var_from_line,',',index+1);
  		if(index == (-1)) continue;
  		SpawnX = floatstr(var_from_line);

  		index = token_by_delim(line,var_from_line,',',index+1);
  		if(index == (-1)) continue;
  		SpawnY = floatstr(var_from_line);

  		index = token_by_delim(line,var_from_line,',',index+1);
  		if(index == (-1)) continue;
  		SpawnZ = floatstr(var_from_line);

  		index = token_by_delim(line,var_from_line,',',index+1);
  		if(index == (-1)) continue;
  		SpawnRot = floatstr(var_from_line);

  		// Read Color1, Color2
  		index = token_by_delim(line,var_from_line,',',index+1);
  		if(index == (-1)) continue;
  		Color1 = strval(var_from_line);

  		index = token_by_delim(line,var_from_line,';',index+1);
  		Color2 = strval(var_from_line);

  		//printf("%d|%f|%f|%f|%f|%d|%d",vehicletype,
  		    //SpawnX,SpawnY,SpawnZ,SpawnRot,Color1,Color2);

		AddStaticVehicleEx(vehicletype,SpawnX,SpawnY,SpawnZ,SpawnRot,Color1,Color2,-1);

		vehicles_loaded++;
	}

	fclose(file_ptr);
	printf("Loaded %d vehicles from: %s",vehicles_loaded,filename);
	return vehicles_loaded;
}
//-------------------------------------------------------------------------------------
token_by_delim(const string[], return_str[], delim, start_index)
{
	new x=0;
	while(string[start_index] != EOS && string[start_index] != delim) {
	    return_str[x] = string[start_index];
	    x++;
	    start_index++;
	}
	return_str[x] = EOS;
	if(string[start_index] == EOS) start_index = (-1);
	return start_index;
}

La mn a functionat ,orasul Lv era gol si dupa ce am pus asta in acel Gm au aparut masinile ,deci nu vad dc nu ar merge si la voi.

f07xw6.gifSunt inofensiv dar gandul meu e criminal
Link to comment
Share on other sites

  • 4 weeks later...
  • 6 months later...

Bv Am facut fix ca tine dar nimik 

E:\SERVAR~1\GAMEMO~1\hHD-ST.pwn(535) : error 001: expected token: "-identifier-", but found "-integer value-"
E:\SERVAR~1\GAMEMO~1\hHD-ST.pwn(538) : error 022: must be lvalue (non-constant)
E:\SERVAR~1\GAMEMO~1\hHD-ST.pwn(538) : warning 215: expression has no effect
E:\SERVAR~1\GAMEMO~1\hHD-ST.pwn(3151) : warning 203: symbol is never used: "DOCP_OnGameModeInit"
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.

<a href='http://www.yhcbux.com/?ref=sice'><img src='http://www.yhcbux.com/images/banner1.gif'></a>

Link to comment
Share on other sites

  • 4 months later...

Bv Am facut fix ca tine dar nimik 

E:\SERVAR~1\GAMEMO~1\hHD-ST.pwn(535) : error 001: expected token: "-identifier-", but found "-integer value-"
E:\SERVAR~1\GAMEMO~1\hHD-ST.pwn(538) : error 022: must be lvalue (non-constant)
E:\SERVAR~1\GAMEMO~1\hHD-ST.pwn(538) : warning 215: expression has no effect
E:\SERVAR~1\GAMEMO~1\hHD-ST.pwn(3151) : warning 203: symbol is never used: "DOCP_OnGameModeInit"
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.

Mie imi da error aia cu don't send  :-\

Mie imi merge oricum. Bravo ( +1 de la mine pt Respect)

845819803.png

default.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Content

    • By TheGodfather
      Salut, masinile se respawneaza la un interval de timp daca cineva nu e in ele. Am pus peste tot unde e SetVehicleToRespawn() un mesaj unic, ca sa imi dau seama unde e problema. Dar cand masina se respawneaza nu apare niciun mesaj, tin sa mentionez ca mesajul e pus cu SendClientMessageToAll. Deci nu exista sansa sa se fi trimis si sa nu il fi vazut. Am gamemode hpq123 bhood.
    • By CenzoR
      Salut! Am problema cand intru in masina persoanala nu imi arata detalile acesteia, de ex cate zile are, km, culorile.
      Scriptul este deja pus in gamemode (nu este anulat)
      Ma poate ajuta cineva?
    • By salexm93
      Salut ,pot adauga cod la apelarea functiilor native ? De ex la CreatePickup am nevoie sa salvez date pe care sa le accesez la OnPlayerPickUpPickup(playerid, pickupid)
    • By Tefyuu
      Salut , in gamemode ul burned by waller , cum adaug pet in shop ? am incercat eu ceva dar nu a aparut si am zis sa va intreb
    • By FlobertRO
      Buna , am si eu o problema . Mi-se restarteaza serverulul random . In server_log am gasit asta : 
      Stie cineva ce pot face  Va rog ❤️ . Multumesc frumos
       
       
      [23:17:26] [join] rezana has joined the server (1:---------------------) [23:17:26] [debug] Run time error 4: "Array index out of bounds" [23:17:26] [debug] Accessing element at index 1 past array upper bound 0 [23:17:26] [debug] AMX backtrace: [23:17:26] [debug] #0 00200b24 in ?? (... <1 argument>) at GM.pwn:8108 [23:17:26] [debug] #1 000aef80 in public MP_OPC (playerid=1) at C:\Users\xda\Desktop\gamemode-impact\gamemode-rpg-impact\pawno\include\YSI\y_hooks/impl.inc:633 [23:17:26] [debug] #2 native CallLocalFunction () from samp03svr [23:17:26] [debug] #3 0000c77c in public SSCANF_OnPlayerConnect (playerid=1) at C:\Users\xda\Desktop\gamemode-impact\gamemode-rpg-impact\pawno\include\mSelection.inc:432 [23:17:26] [debug] #4 00003210 in public Itter_OnPlayerConnect (playerid=1) at C:\Users\xda\Desktop\gamemode-impact\gamemode-rpg-impact\pawno\include\sscanf2.inc:236 [23:17:26] [debug] #5 00001684 in public OnPlayerConnect (playerid=1) at C:\Users\Florin\Dxda\gamemode-impact\gamemode-rpg-impact\pawno\include\YSI\y_iterate.inc:646
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.