[Ajuda] Quando o player Entra no Carro.
#1

Oi Galera, tava pensando em fazer uma verificaзгo, Para quando o player entrar em determinado carro, checar seu score, e assim, proibir a entrada dele no veнculo.

Tava pensando algo como :

pawn Code:
if(GetPlayerScore(playerid) != 20)  return SendClientMessage(playerid,Cinza_Escuro,"[x] Vocк Nгo tem Score Suficiente Para Dirigir esse Veнculo ");
Na Public

public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{


Mais eu queria saber, como eu defino essa verificaзгo, somente para tal carro.

Eu precisaria do ID do veiculo, e algum cуdigo amais, para poder barrar players de entrar em determinados carros, com menos de 20 Score.

Os veнculos seriam , Hydra, Hunter e Rhino.

Alguйm pode dar uma forзa ?

Obrigado xD
Reply
#2

PHP Code:
public OnPlayerEnterVehicle(playeridvehicleidispassenger) {
      if(
GetVehicleModel(vehicleid) == 520) {
            if(
GetPlayerScore(playerid) < 20) {
                  
RemovePlayerFromVehicle(vehicleid);
            }
            else return 
0;
      }
      return 
1;

Aн Estб , Usei de Exemplo o Hydra
Reply
#3

Quote:
Originally Posted by .FuneraL.
View Post
PHP Code:
public OnPlayerEnterVehicle(playeridvehicleidispassenger) {
      if(
GetVehicleModel(vehicleid) == 520) {
            if(
GetPlayerScore(playerid) < 20) {
                  
RemovePlayerFromVehicle(vehicleid);
            }
            else return 
0;
      }
      return 
1;

Aн Estб , Usei de Exemplo o Hydra
Vou testar aqui, e criar de acordo com sua base. de qualquer forma, valeu
Reply
#4

#Funeral

https://sampwiki.blast.hk/wiki/RemovePlayerFromVehicle

Code:
Note: This function will not work when used in OnPlayerEnterVehicle because the player isn't in the vehicle yet at the time the callback is called. Suggested using OnPlayerStateChange instead.

#Traduзгo

Nota: Esta funзгo nгo funciona quando usado em OnPlayerEnterVehicle porque o jogador nгo estб no veнculo ainda na йpoca do retorno de chamada й chamado. Sugeriu o uso OnPlayerStateChange vez.
RemovePlayerFromVehicle nгo irб funcionar em OnPlayerEnterVehicle.
Reply
#5

Quote:
Originally Posted by Ouro
View Post
#Funeral

https://sampwiki.blast.hk/wiki/RemovePlayerFromVehicle

Code:
Note: This function will not work when used in OnPlayerEnterVehicle because the player isn't in the vehicle yet at the time the callback is called. Suggested using OnPlayerStateChange instead.

#Traduзгo

Nota: Esta funзгo nгo funciona quando usado em OnPlayerEnterVehicle porque o jogador nгo estб no veнculo ainda na йpoca do retorno de chamada й chamado. Sugeriu o uso OnPlayerStateChange vez.
RemovePlayerFromVehicle nгo irб funcionar em OnPlayerEnterVehicle.
Realmente, Nгo Deu :\
Dai й sу usar a mesma lуgica, em outra public certo ?
Reply
#6

Quote:
Originally Posted by Lucas-Fc
View Post
Realmente, Nгo Deu :\
Dai й sу usar a mesma lуgica, em outra public certo ?
Sim, Use na OnPlayerStateChange...

@Ouro
Nгo tinha visto a Observaзгo, Desculpe
Reply
#7

Quote:
Originally Posted by .FuneraL.
View Post
Sim, Use na OnPlayerStateChange...

@Ouro
Nгo tinha visto a Observaзгo, Desculpe
Tentei usar na OnPlayerStateChange Mais me confundi todo '-' Deu 4 Erros.
Reply
#8

Tente deste modo:

Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	new vehicleid;
	vehicleid = GetPlayerVehicleID(playerid);

	if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER && GetPlayerScore(playerid) < 1)
	{
		if(GetVehicleModel(vehicleid) == 425 || GetVehicleModel(vehicleid) == 432 || GetVehicle Model(vehicleid) == 520)
		{
			SendClientMessage(playerid, -1, "[ERRO] Vocк precisa ter no mнnimo 1 score para dirigir este veнculo!");
			RemovePlayerFromVehicle(playerid);
		}
	}
	return 1;
}
Reply
#9

Erros :\

pawn Code:
C:\Users\Lucas\Desktop\Servidor\gamemodes\GM.pwn(416) : error 017: undefined symbol "GetVehicle"
C:\Users\Lucas\Desktop\Servidor\gamemodes\GM.pwn(416) : error 017: undefined symbol "Model"
C:\Users\Lucas\Desktop\Servidor\gamemodes\GM.pwn(416) : error 029: invalid expression, assumed zero
C:\Users\Lucas\Desktop\Servidor\gamemodes\GM.pwn(416) : fatal error 107: too many error messages on one line
Linha :

pawn Code:
if(GetVehicleModel(vehicleid) == 425 || GetVehicleModel(vehicleid) == 432 || GetVehicle Model(vehicleid) == 520)
Reply
#10

Quote:
Originally Posted by Lucas-Fc
View Post
Erros :\

pawn Code:
C:\Users\Lucas\Desktop\Servidor\gamemodes\GM.pwn(416) : error 017: undefined symbol "GetVehicle"
C:\Users\Lucas\Desktop\Servidor\gamemodes\GM.pwn(416) : error 017: undefined symbol "Model"
C:\Users\Lucas\Desktop\Servidor\gamemodes\GM.pwn(416) : error 029: invalid expression, assumed zero
C:\Users\Lucas\Desktop\Servidor\gamemodes\GM.pwn(416) : fatal error 107: too many error messages on one line
Linha :

pawn Code:
if(GetVehicleModel(vehicleid) == 425 || GetVehicleModel(vehicleid) == 432 || GetVehicle Model(vehicleid) == 520)
Olhem Isso :\
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)