My OnPlayerEnterVehicle is broken.
#1

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new string[256];
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 498) {
        SendClientMessage(playerid, COLOR_GREY, "You are in a Boxville, use /delivery to start the mission.");
    }
    //===========================================START OF POLICE===============================================
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 599) {
      if(PlayerInfo[playerid][pFaction] == 1) {
             format(string, sizeof(string), "This is a faction only car. It belongs to your faction, the %s.", DynamicFactions[1][fName]);
             SendClientMessage(playerid, COLOR_WHITE, string);
        } else {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid, COLOR_WHITE, "This is a faction only car!");
      }
    }
    return 1;
}
I can enter the Police Car (model id 599), and the Boxville (model id 49, but nothing is sent.
Reply
#2

OnPlayerEnterVehicle isnt the best choice, it's better to go with OnPlayerStateChange.


Here's an example (i wouldnt do it this way personally, as you have to add EVERY vehicle mission statically, but w/e). Here's how you detect if they entered a boxvill (or w/e it is named).

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if((newstate == PLAYER_STATE_DRIVER) && (oldstate == PLAYER_STATE_ONFOOT))
	{
		if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 498)
		{
		  SendClientMessage(playerid, 0xFFFFFFFF, "You entered a boxvill, neat!");
		  return 1;
		}
	}
	return 1;
}
Reply
#3

How would you do it then?
Reply
#4

Quote:
Originally Posted by jameskmonger
How would you do it then?
I would make a array to store the available mission vehicles / the text. Once they get in the vehicle, do a small loop through the array and check if their in a vehicle that has a mission; if they are, show them the appropriate text.

It may be a little advanced for you though. I suggest you read about arrays/loops, and do it like that. Its up to you though.
Reply
#5

I know arrays and loops, I program Java.
Reply
#6

Regarding this:
pawn Код:
format(string, sizeof(string), "This is a faction only car. It belongs to your faction, the %s.", DynamicFactions[1][fName]);
             SendClientMessage(playerid, COLOR_WHITE, string);
It currently says this:
Quote:

This is a faction only car. It belongs to your faction, the .

Reply
#7

Quote:
Originally Posted by jameskmonger
Regarding this:
pawn Код:
format(string, sizeof(string), "This is a faction only car. It belongs to your faction, the %s.", DynamicFactions[1][fName]);
            SendClientMessage(playerid, COLOR_WHITE, string);
It currently says this:
Quote:

This is a faction only car. It belongs to your faction, the .

did you format/assign the names to said string ?
Reply
#8

Yes. fName is in the DynamicFactions enum, and the car belongs to faction 1.
Reply
#9

Quote:
Originally Posted by jameskmonger
Yes. fName is in the DynamicFactions enum, and the car belongs to faction 1.
That doesnt mean it knows the factions name.


When the gm/fs loads:

Код:
DynamicFactions[1][fName] = "LeetFactionYo"; //Make sure the name is in the boundaries of the array
Reply
#10

It's loaded from a .cfg file, and it works fine when it runs (it prints it out like this
Quote:

Faction ID: 1 Loaded, Name: Sherrif Department, Spawn: X:@ Y:@ Z:@

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)