SA-MP Forums Archive
Just a small problem that all of u masterscripters can easly solve... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Just a small problem that all of u masterscripters can easly solve... (/showthread.php?tid=279215)



Just a small problem that all of u masterscripters can easly solve... - knackworst - 25.08.2011

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


Re: Just a small problem that all of u masterscripters can easly solve... - Amel_PAtomAXx - 25.08.2011

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;
    }



Re: Just a small problem that all of u masterscripters can easly solve... - knackworst - 25.08.2011

Errors, lots of them :/


Re: Just a small problem that all of u masterscripters can easly solve... - Rssc - 25.08.2011

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?


Re: Just a small problem that all of u masterscripters can easly solve... - knackworst - 25.08.2011

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...


AW: Just a small problem that all of u masterscripters can easly solve... - Meta - 25.08.2011

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;
    }



Re: Just a small problem that all of u masterscripters can easly solve... - Bakr - 26.08.2011

@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.


Re: Just a small problem that all of u masterscripters can easly solve... - knackworst - 26.08.2011

Код:
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


Re: Just a small problem that all of u masterscripters can easly solve... - knackworst - 26.08.2011

Is there really none to help me!??


Re: Just a small problem that all of u masterscripters can easly solve... - jameskmonger - 26.08.2011

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;
    }