Just a small problem that all of u masterscripters can easly solve...
#1

Hi, me again :/


I got another little problem.
I made something that when a player has a certain score, it cannot enter a vehicle wich requires a higher score than the actual player score...
I thought my script would work, and I got no errors... but when I come ingame it seems that it did not work...

Код:
//OnPlayerState callback up here
if(newstate == 2)
    {
    new vehicle;
    vehicle = GetVehicleModel(GetPlayerVehicleID(playerid));
	if(vehicle == 421)
        {
            if(gTeam[playerid] == TEAM_DRIVERS && GetPlayerScore(playerid) < 120 ) //if the player is in the right team and has the right score
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "U need 120 for this car");
            	return 1;
            }
            else
            {
            	return 1;
            }
        }

	return 1;
    }
//Other code
Please hel
Reply
#2

try this :
pawn Код:
if(newstate == 2)
    {
        new vehicle;
        vehicle = GetVehicleModel(GetPlayerVehicleID(playerid));
    if(vehicle == 421)
        {
            if(gTeam[playerid] == TEAM_DRIVERS)
            {
            if(GetPlayerScore(playerid)=> 120)
            {
            }
            else
            {
       
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "U need 120 for this car");
           
            }
           
        }
        }
    return 1;
    }
Reply
#3

Errors, lots of them :/
Reply
#4

What's wrong? You can still drive the car when lower than the score required? You canґt drive the car when having 120 of score?
Reply
#5

To Amel, fixed the errors and warnings, but still I can enter the car with only 40 score

to RSSC I must have something that when I wanna enter a vehicle with less than 120 score, i get removed from it...
Reply
#6

pawn Код:
//OnPlayerState callback up here
if(newstate == 2)
    {
    new vehicle;
    vehicle = GetVehicleModel(GetPlayerVehicleID(playerid));
    if(vehicle == 421)
        {
            if(!(gTeam[playerid] == TEAM_DRIVERS && GetPlayerScore(playerid) >= 120)) //if the player is in the right team and has the right score
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "U need 120 for this car");
                return 1;
            }
        }

    return 1;
    }
Reply
#7

@Meta: You check if the players team is NOT TEAM_DRIVERS.

I don't see anything wrong with the code you originally posted. The only thing I can think of is something prior to this code being called is stopping it, or you have the incorrect vehicle model. Which vehicle are you trying to check exactly? Also, please post your whole OnPlayerStateChange callback.
Reply
#8

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2)
    {
		SendClientMessage(playerid, COLOR_SEXYGREEN, "Use /seatbelt to reduce the health u loose in a car accident.");
	}

//==============================================================================
//Team cars_Drivers
//==============================================================================

    if(newstate == 2)
    {
    new vehicle;
    vehicle = GetVehicleModel(GetPlayerVehicleID(playerid));
	if(vehicle == 516 || vehicle == 409 || vehicle == 421)
        {
            if(gTeam[playerid] == TEAM_COPS)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "Only Drivers can use this car!!");
            	return 1;
            }
            else if(gTeam[playerid] == TEAM_BANDIT)
            {
                SendClientMessage(playerid, COLOR_LIGHTBLUE, "U stole a Drivers car, be carefull!");
                SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 1);
                new string[128];
                format(string,sizeof(string),"%s has stolen a drivers car!",playerid);
  				SendClientMessageToAllCops(string);
            	return 1;
            }
        }

	return 1;
    }
    
//==============================================================================
//Score cars_Drivers
//==============================================================================

    if(newstate == 2)
    {
        new vehicle;
        vehicle = GetVehicleModel(GetPlayerVehicleID(playerid));
        
		if(vehicle == 421)
        {
            if(gTeam[playerid] == TEAM_DRIVERS)
            {
	            if(GetPlayerScore(playerid) < 120)
	            {
	            }
	            else
	            {

	                RemovePlayerFromVehicle(playerid);
	                SendClientMessage(playerid, COLOR_RED, "U need 120 for this car");

	            }

	        }
	        }
	    return 1;
	    }
    
//==============================================================================
//Work for Drivers LVL 1
//==============================================================================
    if(newstate == 2)
    {
    new vehicle;
    vehicle = GetVehicleModel(GetPlayerVehicleID(playerid));
	if(vehicle == 516)
        {
            if(gTeam[playerid] == TEAM_DRIVERS)
            {
           	    GameTextForPlayer(playerid, "~w~ U entered A ~y~Lvl 1~w~ vehicle. Please drive to the ~r~ Red marker~w~, located in front of the club. to Work", 5000, 5);
     			startworkpickup = CreatePickup(1317, 14, 10,0,2, -1);
            	return 1;
            }
            else
            {
            	return 1;
            }
        }

	return 1;
    }
    return 1;
}
here, some parts won't work either, because I'm busy fixing it...
anyways, the vehicle I want to call is a nebula
Reply
#9

Is there really none to help me!??
Reply
#10

pawn Код:
if(newstate == 2) {
        new vehicle;
        vehicle = GetVehicleModel(GetPlayerVehicleID(playerid));
        if(vehicle == 421) {
            if(gTeam[playerid] == TEAM_DRIVERS) {
                if(GetPlayerScore(playerid) < 120) {
                    RemovePlayerFromVehicle(playerid);
                    SendClientMessage(playerid, COLOR_RED, "You need a score of at least 120 to drive this car.");
                }
            }
        }
        return 1;
    }
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)