SA-MP Forums

Go Back   SA-MP Forums > Non-English > Languages > Português/Portuguese

Reply
 
Thread Tools Display Modes
Old 26/03/2015, 08:00 PM   #1
JoshNudock
Huge Clucker
 
JoshNudock's Avatar
 
Join Date: Aug 2014
Posts: 491
Reputation: 14
Default OnPlayerConnect - OnGameModeInt

Olá pessoal! boa tarde e daqui apouco "Boa Noite", tipo pessoal.. tenho um código aqui e o mesmo desejo mudar, tipo é assim, a pessoa loga e o veiculo nasce.. não quero assim.. quero que na hora que o servidor liga o carro do mesmo é criado.. mais deste seguinte modo abaixo é criando apenas caso a pessoa loga(me corrija caso esteja errado).

HTML Code:
public OnPlayerConnect(playerid)
{
	LoadVehicleForPlayer(playerid);
    return 1;
}

stock LoadVehicleForPlayer(playerid)
{
	new name[MAX_PLAYER_NAME], file[50];
	GetPlayerName(playerid, name, sizeof(name));
	format(file, sizeof(file), "Vehicles/%s.ini", name);
	if(fexist(file))
	{
		VehicleInfo[vid][vID] = dini_Int(file, "Vehicle ID");
		VehicleInfo[vid][vColor1] = dini_Int(file, "Color 1");
		VehicleInfo[vid][vColor2] = dini_Int(file, "Color 2");
		VehicleInfo[vid][vX] = dini_Float(file, "Position X");
		VehicleInfo[vid][vY] = dini_Float(file, "Position Y");
		VehicleInfo[vid][vZ] = dini_Float(file, "Position Z");
		VehicleInfo[vid][vA] = dini_Float(file, "Facing Angle");
		AddStaticVehicle(VehicleInfo[vid][vID], VehicleInfo[vid][vX], VehicleInfo[vid][vY], VehicleInfo[vid][vZ], VehicleInfo[vid][vA], VehicleInfo[vid][vColor1], VehicleInfo[vid][vColor2]);
		printf("%s's vehicle ID: %d - LOADED", name, VehicleInfo[vid][vID]);
		strmid(VehicleInfo[vid][vOwner], dini_Get(file, "Owner"), false, strlen(dini_Get(file, "Owner")), MAX_PLAYER_NAME);
	}
}
Sei lá queria colocar no GameModeInt.. mais não sei como.. pois tentei e bugou tudo e perdi o codigo então apelei para os profissionais do fórum SA-MP! por favor galera.. alguém.
__________________
Quote:
[IMG]https://lh3.******usercontent.com/-yRs0SvXCSg8/UfDOh9ZUBhI/AAAAAAAAAAw/14h233Cj-zM/w400-h200-no/bloggif_51f0ce6704cb0.gif[/IMG]
JoshNudock is offline   Reply With Quote
Old 26/03/2015, 08:21 PM   #2
Hiuship
Huge Clucker
 
Join Date: Sep 2010
Posts: 315
Reputation: 13
Default Re: OnPlayerConnect - OnGameModeInt

Deste modo é impossível, pois os veículos são salvos com o nome do player.
E o samp não fornece função de pegar nome de arquivos.

Você teria que refazer seu sistema para trabalhar com ids nos veículos e carregar eles por esse id, e atribuir o dono do veiculo salvando o nome do proprietário ou o id do veiculo na conta do proprietário.
__________________

Clique no banner e confira os planos!!
Hiuship is offline   Reply With Quote
Old 26/03/2015, 08:58 PM   #3
JoshNudock
Huge Clucker
 
JoshNudock's Avatar
 
Join Date: Aug 2014
Posts: 491
Reputation: 14
Default Re: OnPlayerConnect - OnGameModeInt

Como posso fazer amigo? me de alguns exemplos baseado em meu código que fiz acima?
__________________
Quote:
[IMG]https://lh3.******usercontent.com/-yRs0SvXCSg8/UfDOh9ZUBhI/AAAAAAAAAAw/14h233Cj-zM/w400-h200-no/bloggif_51f0ce6704cb0.gif[/IMG]
JoshNudock is offline   Reply With Quote
Old 26/03/2015, 09:19 PM   #4
maikonk
Huge Clucker
 
maikonk's Avatar
 
Join Date: Sep 2010
Location: Curitiba
Posts: 247
Reputation: 3
Default Re: OnPlayerConnect - OnGameModeInt

Quote:
#define MAX_VEHICLES 100
procura por essa linha :
Quote:
new VehicleInfo[MAX_PLAYERS]...
e troque por:
Quote:
new VehicleInfo[MAX_VEHICLES]...
No OnGameModeInit:
Code:
new file[50];
	 for(new car = 0; car < sizeof(MAX_VEHICLES) ; car++)
	 {
		format(file, sizeof(file), "Veiculos/%d.ini", car);
		if(fexist(file))
		{
			VehicleInfo[car][vID] = dini_Int(file, "Vehicle ID");
			VehicleInfo[car][vColor1] = dini_Int(file, "Color 1");
			VehicleInfo[car][vColor2] = dini_Int(file, "Color 2");
			VehicleInfo[car][vX] = dini_Float(file, "Position X");
			VehicleInfo[car][vY] = dini_Float(file, "Position Y");
			VehicleInfo[car][vZ] = dini_Float(file, "Position Z");
			VehicleInfo[car][vA] = dini_Float(file, "Facing Angle");
			AddStaticVehicle(VehicleInfo[car][vID], VehicleInfo[car][vX], VehicleInfo[car][vY], VehicleInfo[car][vZ], VehicleInfo[car][vA], VehicleInfo[car][vColor1], VehicleInfo[car][vColor2]);
			printf("vehicle ID: %d - LOADED", VehicleInfo[car][vID]);
		}
	}
nao testei so copiei de um sistema q eu tinha aqui q funciona, testa ai '-'

@Edit
Troque o nome dos carro por numero, Exemplo: 1 2 3 até 99
maikonk is offline   Reply With Quote
Old 26/03/2015, 09:48 PM   #5
JoshNudock
Huge Clucker
 
JoshNudock's Avatar
 
Join Date: Aug 2014
Posts: 491
Reputation: 14
Default Re: OnPlayerConnect - OnGameModeInt

Quote:
Originally Posted by maikonk View Post
procura por essa linha :


e troque por:


No OnGameModeInit:
Code:
new file[50];
	 for(new car = 0; car < sizeof(MAX_VEHICLES) ; car++)
	 {
		format(file, sizeof(file), "Veiculos/%d.ini", car);
		if(fexist(file))
		{
			VehicleInfo[car][vID] = dini_Int(file, "Vehicle ID");
			VehicleInfo[car][vColor1] = dini_Int(file, "Color 1");
			VehicleInfo[car][vColor2] = dini_Int(file, "Color 2");
			VehicleInfo[car][vX] = dini_Float(file, "Position X");
			VehicleInfo[car][vY] = dini_Float(file, "Position Y");
			VehicleInfo[car][vZ] = dini_Float(file, "Position Z");
			VehicleInfo[car][vA] = dini_Float(file, "Facing Angle");
			AddStaticVehicle(VehicleInfo[car][vID], VehicleInfo[car][vX], VehicleInfo[car][vY], VehicleInfo[car][vZ], VehicleInfo[car][vA], VehicleInfo[car][vColor1], VehicleInfo[car][vColor2]);
			printf("vehicle ID: %d - LOADED", VehicleInfo[car][vID]);
		}
	}
nao testei so copiei de um sistema q eu tinha aqui q funciona, testa ai '-'

@Edit
Troque o nome dos carro por numero, Exemplo: 1 2 3 até 99
HTML Code:
enum vInfo
{
	vOwner[MAX_PLAYER_NAME],
	vID,
	vColor1,
	vColor2,
	Float:vX,
	Float:vY,
	Float:vZ,
	Float:vA
}

new VehicleInfo[MAX_VEHICLES][vInfo], vid;
Uma amigo.. aqui tem isso..

HTML Code:
#define MAX_CARS 1000 //Será que compensa deixar 1000 ou deixar 100 e posso colocar a variável CARS para VEHICLES?
 e o que muda?

#define MAX_VEHICLES 100
@Edit
Quote:
Originally Posted by maikonk View Post
@Edit
Troque o nome dos carro por numero, Exemplo: 1 2 3 até 99
Não entendi.. vc diz, 1 é o primeiro veiculo da wiki, 2 segundo e assim por diante?
Code:
C:\Users\Administrador PC\Desktop\Nova pasta (2)\filterscripts\Concessonaria.pwn(10) : warning 201: redefinition of constant/macro (symbol "MAX_VEHICLES")
C:\Users\Administrador PC\Desktop\Nova pasta (2)\filterscripts\Concessonaria.pwn(33) : error 025: function heading differs from prototype
C:\Users\Administrador PC\Desktop\Nova pasta (2)\filterscripts\Concessonaria.pwn(36) : error 020: invalid symbol name ""
C:\Users\Administrador PC\Desktop\Nova pasta (2)\filterscripts\Concessonaria.pwn(36) : error 036: empty statement
C:\Users\Administrador PC\Desktop\Nova pasta (2)\filterscripts\Concessonaria.pwn(36) : error 017: undefined symbol "car"
C:\Users\Administrador PC\Desktop\Nova pasta (2)\filterscripts\Concessonaria.pwn(36) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


5 Errors.
erro:
HTML Code:
	 for(new car = 0; car < sizeof(MAX_VEHICLES) ; car++) //linha 36
vlw! reputado!
__________________
Quote:
[IMG]https://lh3.******usercontent.com/-yRs0SvXCSg8/UfDOh9ZUBhI/AAAAAAAAAAw/14h233Cj-zM/w400-h200-no/bloggif_51f0ce6704cb0.gif[/IMG]
JoshNudock is offline   Reply With Quote
Old 26/03/2015, 10:40 PM   #6
Cleyson
Gangsta
 
Cleyson's Avatar
 
Join Date: Feb 2014
Location: Vitória - ES
Posts: 646
Reputation: 151
Default Re: OnPlayerConnect - OnGameModeInt

PHP Code:
public OnGameModeInit()
{
    for(new 
0MAX_PLAYERSi++)
    {
        new 
name[MAX_PLAYER_NAME], file[50];
        
GetPlayerName(inamesizeof(name));
        
        
format(filesizeof(file), "Vehicles/%s.ini"name);
        if(
fexist(file))
        {
            
VehicleInfo[i][vID] = dini_Int(file"Vehicle ID");
            
VehicleInfo[i][vColor1] = dini_Int(file"Color 1");
            
VehicleInfo[i][vColor2] = dini_Int(file"Color 2");
            
VehicleInfo[i][vX] = dini_Float(file"Position X");
            
VehicleInfo[i][vY] = dini_Float(file"Position Y");
            
VehicleInfo[i][vZ] = dini_Float(file"Position Z");
            
VehicleInfo[i][vA] = dini_Float(file"Facing Angle");
            
AddStaticVehicle(VehicleInfo[i][vID], VehicleInfo[i][vX], VehicleInfo[i][vY], VehicleInfo[i][vZ], VehicleInfo[i][vA], VehicleInfo[i][vColor1], VehicleInfo[i][vColor2]);
            
printf("%s's vehicle ID: %d - LOADED"nameVehicleInfo[i][vID]);
            
strmid(VehicleInfo[i][vOwner], dini_Get(file"Owner"), falsestrlen(dini_Get(file"Owner")), MAX_PLAYER_NAME);
        }
    }
    return 
1;

__________________
Breaking Life RPG
Coming soon... Wait...

Last edited by Cleyson; 27/03/2015 at 12:48 AM.
Cleyson is offline   Reply With Quote
Old 27/03/2015, 12:46 AM   #7
JoshNudock
Huge Clucker
 
JoshNudock's Avatar
 
Join Date: Aug 2014
Posts: 491
Reputation: 14
Default Re: OnPlayerConnect - OnGameModeInt

Quote:
Originally Posted by Cleyson View Post
PHP Code:
public OnGameModeInit()
{
    for(new 
0MAX_PLAYERSi++)
    {
        new 
name[MAX_PLAYER_NAME], file[50];
        
GetPlayerName(inamesizeof(name));
        
        
format(filesizeof(file), "Vehicles/%s.ini"i);
        if(
fexist(file))
        {
            
VehicleInfo[i][vID] = dini_Int(file"Vehicle ID");
            
VehicleInfo[i][vColor1] = dini_Int(file"Color 1");
            
VehicleInfo[i][vColor2] = dini_Int(file"Color 2");
            
VehicleInfo[i][vX] = dini_Float(file"Position X");
            
VehicleInfo[i][vY] = dini_Float(file"Position Y");
            
VehicleInfo[i][vZ] = dini_Float(file"Position Z");
            
VehicleInfo[i][vA] = dini_Float(file"Facing Angle");
            
AddStaticVehicle(VehicleInfo[i][vID], VehicleInfo[i][vX], VehicleInfo[i][vY], VehicleInfo[i][vZ], VehicleInfo[i][vA], VehicleInfo[i][vColor1], VehicleInfo[i][vColor2]);
            
printf("%s's vehicle ID: %d - LOADED"nameVehicleInfo[i][vID]);
            
strmid(VehicleInfo[i][vOwner], dini_Get(file"Owner"), falsestrlen(dini_Get(file"Owner")), MAX_PLAYER_NAME);
        }
    }
    return 
1;

Vlw cara! vc é esperto! reputado!

@edit
Esse codigo é funcional? deu esse erro.. no codigo..

Code:
C:\Users\Administrador PC\Desktop\Nova pasta (2)\filterscripts\Concessonaria.pwn(10) : warning 201: redefinition of constant/macro (symbol "MAX_VEHICLES")
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.
Linha do erro é

HTML Code:
#define MAX_VEHICLES 100
__________________
Quote:
[IMG]https://lh3.******usercontent.com/-yRs0SvXCSg8/UfDOh9ZUBhI/AAAAAAAAAAw/14h233Cj-zM/w400-h200-no/bloggif_51f0ce6704cb0.gif[/IMG]
JoshNudock is offline   Reply With Quote
Old 27/03/2015, 01:18 AM   #8
HardWar
Huge Clucker
 
Join Date: Oct 2012
Posts: 388
Reputation: 44
Default Re: OnPlayerConnect - OnGameModeInt

Coloca isso em cima dessa define:

pawn Code:
#undef MAX_VEHICLES
HardWar is offline   Reply With Quote
Old 27/03/2015, 02:58 AM   #9
JoshNudock
Huge Clucker
 
JoshNudock's Avatar
 
Join Date: Aug 2014
Posts: 491
Reputation: 14
Default Re: OnPlayerConnect - OnGameModeInt

Esse daqui até tendei resolver mais n deu..

HTML Code:
enum vInfo
{
	vOwner[MAX_PLAYER_NAME],
	vID,
	vColor1,
	vColor2,
	Float:vX,
	Float:vY,
	Float:vZ,
	Float:vA
}

new VehicleInfo[MAX_VEHICLES][vInfo], vid; //erro aqui afs
o que faço? por favor..
__________________
Quote:
[IMG]https://lh3.******usercontent.com/-yRs0SvXCSg8/UfDOh9ZUBhI/AAAAAAAAAAw/14h233Cj-zM/w400-h200-no/bloggif_51f0ce6704cb0.gif[/IMG]
JoshNudock is offline   Reply With Quote
Old 27/03/2015, 02:59 AM   #10
HardWar
Huge Clucker
 
Join Date: Oct 2012
Posts: 388
Reputation: 44
Default Re: OnPlayerConnect - OnGameModeInt

Qual o erro?
HardWar is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with ongamemodeint verlaj Scripting Help 5 02/06/2014 03:05 PM
[Ajuda] Com OnPlayerConnect Alisson Silva Alves Português/Portuguese 27 09/11/2013 05:02 PM
[Ajuda] OnPlayerConnect CharlieBrown Português/Portuguese 5 01/10/2013 01:33 AM
[Ajuda] OnPlayerConnect [KoS]Izaac Português/Portuguese 3 12/03/2013 11:55 PM
OnPlayerConnect. iGetty Help Archive 5 21/07/2011 12:06 AM


All times are GMT. The time now is 02:12 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.