[Help] if(IsPlayerInVehicle(playerid, X);
#1

Hi,

First of all, sorry about my english, It's not my lenguaje.
Okay, let's start. Today, I've been trying to make a gamemode which has Hunters and Hydras. If you want to drive them, you've got to have at least, 50 points (score) saved in the .txt dini.
Here's my question: how tha fuck can I build it? I've been trying for several hours and I couldn't do it.
I started denominating the first hydra with a
new then, I made a timer so, when the player gets into a car, the timer starts and checks if the car which the player entered is the Hydra. Do you people get me? here's the code:


Код:
forward CarCheck(playerid, vehicleid);
new hydraUSA1;
Код:
OnGameModeInIt();
hydra1 =	AddStaticVehicleEx(520,317.6323,2052.3049,18.3789,178.9925,86,86,10000);
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	SetTimer("CarCheck", 100, 1);
	return 1;
}
Код:
// ------------------------------> Timer CARCHECK <-----------------------------
public CarCheck(playerid, vehicleid);
{
	GetPlayerVehicleID(playerid);
	if(IsPlayerInVehicle(playerid, hydraUSA1))
	{
	  SendClientMessage(playerid, rojo_03,"-- Something happens... --");
	}
	else
	{
    SendClientMessage(playerid, rojo_03,"||-- Other thing happens... ---");
	}
}
And these are the errors:
Код:
D:\Facu\Cosas\Diseсo\GTA\SERVER\Lucoon\Lucoon\gamemodes\codESP.pwn(144) : warning 202: number of arguments does not match definition
D:\Facu\Cosas\Diseсo\GTA\SERVER\Lucoon\Lucoon\gamemodes\codESP.pwn(664) : error 055: start of function body without function header
D:\Facu\Cosas\Diseсo\GTA\SERVER\Lucoon\Lucoon\gamemodes\codESP.pwn(666) : error 010: invalid function or declaration
D:\Facu\Cosas\Diseсo\GTA\SERVER\Lucoon\Lucoon\gamemodes\codESP.pwn(670) : error 010: invalid function or declaration
D:\Facu\Cosas\Diseсo\GTA\SERVER\Lucoon\Lucoon\gamemodes\codESP.pwn(145) : warning 204: symbol is assigned a value that is never used: "hydraUSA1"
D:\Facu\Cosas\Diseсo\GTA\SERVER\Lucoon\Lucoon\gamemodes\codESP.pwn(145 -- 675) : warning 203: symbol is never used: "ret_memcpy"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Anyway, I've been traying for hours and I couldn't reach the way for doing this. I heard about a filter script or include called "CAR ID" or something like that... It could define cars with id's, so then you would be able to use that id car in conditions/if, etc.

If you could help me defining vehicles and making conditions for them such as "IsPlayerInVehicle(playerid, ambulance) || ambulance = [the car...] or just the right way for doing this, I would appreciate it.
Thanks you.
Facu.
Reply
#2

Ok i think i know what you want, but you are definitely doing it the wrong way.

OnPlayerEnterVehicle occurs when a player starts to enter a vehicle, before they are actually in the car.
This is why you had to use the timer.

Instead use OnPlayerStateChange https://sampwiki.blast.hk/wiki/OnPlayerStateChange checking for PLAYER_STATE_DRIVER as the new state. This occurs when they are actually in the vehicle. No more need for a timer

You are also getting an error from public CarCheck(playerid, vehicleid); you don't need the ";"
and OnGameModeInIt is a script call back you need to fill out, not something you call(normally). https://sampwiki.blast.hk/wiki/OnGameModeInit
And a few other bugs i fixed up.

For your question about how to get vehicle types, use GetVehicleModel

You might want to read through some tutorials on the samp wiki


Here is a corrected version with OnPlayerStateChange instead


pawn Код:
new hydra1 ;

public OnGameModeInit()
{
    hydra1 =    AddStaticVehicleEx(520,317.6323,2052.3049,18.3789,178.9925,86,86,10000);
}
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate);
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(GetVehicleModel(vehicleid)==520) //520 is a hydra model
        {
          SendClientMessage(playerid, rojo_03,"-- Something happens... --");
        }
        else
        {
        SendClientMessage(playerid, rojo_03,"||-- Other thing happens... ---");
        }
    }
}
Reply
#3

Hi,
Thanks you very much Mansonh, it really did help me and I'm using it without any problems in my gamemode right now.

Now a little question: how can I set an exactly value to a PlayerInfo part of the DINI? for example: "Score". With X command, then I add X ammount of score to the DINI instead of using the "++" that only auments the number to plus one.
Thanks.
Facu.
Reply
#4

No problem, hope that makes sense why I did it that way.

For your second question.
Not sure, I haven't used Dini yet, I would post that as a separate topic, someone else should be able to help you.
Reply
#5

Hi,
Yes, I understood why you used that public and the way you did it, it really did help me a lot, thanks again. I'll make an other topic for the other question, thanks for your help.
See you.
Facu.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)