If the player does not have enough scoure Prevent him from ride Hydra , tank or ....
#1

If the player does not have enough scoure Prevent him from ride Hydra , tank or ....

or

500 points is required to select five class
And Class five required for driving tank

please guide me
tanks
Reply
#2

You mean that Only those who have 500 score can enter hydra ? Like Score Limits ? And if the player dosent have limited score he will be automatically Exited ?
Reply
#3

OnPlayerEnterVehicle and GetPlayerScore are your friends.
Reply
#4

Under includes:-
You can edit values (scores).
ex: #define PLAYER_LEVEL1 50 instead of #define PLAYER_LEVEL1 10
PHP код:
#define PLAYER_LEVEL1 10 
#define PLAYER_LEVEL2 20
#define PLAYER_LEVEL3 50
#define PLAYER_LEVEL4 70
#define PLAYER_LEVEL5 100 
OnPlayerStateChange:-
PHP код:
    if(newstate == PLAYER_STATE_DRIVER)
    {
    
        new 
pIscore;
        new 
vehicleid;
        
vehicleid GetPlayerVehicleID(playerid);
        
pIscore GetPlayerScore(playerid);
        if (
GetVehicleModel(vehicleid) == 476 && pIscore PLAYER_LEVEL1//  Rustler
        
{
            
SendClientMessage(playerid,-1,"Your level is not high enough to drive this vehicle, please kill others to gain score!");
            
RemovePlayerFromVehicle(playerid);
        }
        
        else if(
GetVehicleModel(vehicleid) == 447 && pIscore PLAYER_LEVEL2//Seasparrow
        
{
            
            
SendClientMessage(playerid,-1,"Your level is not high enough to drive this vehicle, please kill others to gain score!");
            
RemovePlayerFromVehicle(playerid);
        }
        
        else if(
GetVehicleModel(vehicleid) == 593 && pIscore PLAYER_LEVEL3//Dodo
            
        
{
            
            
RemovePlayerFromVehicle(playerid);
            
SendClientMessage(playerid,-1,"Your level is not high enough to drive this vehicle, please kill others to gain score!");
        }
        
        else if(
GetVehicleModel(vehicleid) == 425 && pIscore PLAYER_LEVEL4//Hunter
            
        
{
            
RemovePlayerFromVehicle(playerid);
            
SendClientMessage(playerid,-1,"Your level is not high enough to drive this vehicle, please kill others to gain score!");
        }
        
        else if(
GetVehicleModel(vehicleid) == 520 && pIscore PLAYER_LEVEL5//Hydra
            
        
{
            
RemovePlayerFromVehicle(playerid);
            
SendClientMessage(playerid,-1,"Your level is not high enough to drive this vehicle, please kill others to gain score!");
        }
    
    
    } 
Edit your vehicle ids and scores.
Reply
#5

PHP код:
public OnPlayerStateChange(playeridnewstateoldstate)
{
      if(
newstate == PLAYER_STATE_DRIVER)
         if(
GetVehicleModel(GetPlayerVehicleID(playerid)) == 520 && GetPlayerScore(playerid) < 500)
               
RemovePlayerFromVehicle(playerid);
     return 
1;

This code will remove player from Hydra if his score is less than 500.
520 is Hydra vehicle Model ID, refer to https://sampwiki.blast.hk/wiki/Vehicle_Model_ID_List for list of vehicle and their model ids.

EDIT: Too late answer has been already posted above.
Reply
#6

Quote:
Originally Posted by Iceblizard
Посмотреть сообщение
You mean that Only those who have 500 score can enter hydra ? Like Score Limits ? And if the player dosent have limited score he will be automatically Exited ?
Exactly
Reply
#7

Quote:
Originally Posted by karemmahmed22
Посмотреть сообщение
Under includes:-
You can edit values (scores).
ex: #define PLAYER_LEVEL1 50 instead of #define PLAYER_LEVEL1 10
PHP код:
#define PLAYER_LEVEL1 10 
#define PLAYER_LEVEL2 20
#define PLAYER_LEVEL3 50
#define PLAYER_LEVEL4 70
#define PLAYER_LEVEL5 100 
OnPlayerStateChange:-
PHP код:
    if(newstate == PLAYER_STATE_DRIVER)
    {
    
        new 
pIscore;
        new 
vehicleid;
        
vehicleid GetPlayerVehicleID(playerid);
        
pIscore GetPlayerScore(playerid);
        if (
GetVehicleModel(vehicleid) == 476 && pIscore PLAYER_LEVEL1//  Rustler
        
{
            
SendClientMessage(playerid,-1,"Your level is not high enough to drive this vehicle, please kill others to gain score!");
            
RemovePlayerFromVehicle(playerid);
        }
        
        else if(
GetVehicleModel(vehicleid) == 447 && pIscore PLAYER_LEVEL2//Seasparrow
        
{
            
            
SendClientMessage(playerid,-1,"Your level is not high enough to drive this vehicle, please kill others to gain score!");
            
RemovePlayerFromVehicle(playerid);
        }
        
        else if(
GetVehicleModel(vehicleid) == 593 && pIscore PLAYER_LEVEL3//Dodo
            
        
{
            
            
RemovePlayerFromVehicle(playerid);
            
SendClientMessage(playerid,-1,"Your level is not high enough to drive this vehicle, please kill others to gain score!");
        }
        
        else if(
GetVehicleModel(vehicleid) == 425 && pIscore PLAYER_LEVEL4//Hunter
            
        
{
            
RemovePlayerFromVehicle(playerid);
            
SendClientMessage(playerid,-1,"Your level is not high enough to drive this vehicle, please kill others to gain score!");
        }
        
        else if(
GetVehicleModel(vehicleid) == 520 && pIscore PLAYER_LEVEL5//Hydra
            
        
{
            
RemovePlayerFromVehicle(playerid);
            
SendClientMessage(playerid,-1,"Your level is not high enough to drive this vehicle, please kill others to gain score!");
        }
    
    
    } 
Edit your vehicle ids and scores.
I should add that this is exactly where?
Reply
#8

If you can look at replies, You'll see i gave you full code for how to do it, Even Though BroZeus Done the same.
Edit: I already said, The defines should be under INCLUDES
The code should be under OnPlayerStateChange
Reply
#9

karemmaahmed22 said First Define under Includes and You know ''OnPlayerStateChange'' Thanks to Karemmahmed22 and also BroZeus

Also you can change the score limit if you want by editing like Changing Define

another one

PHP код:
if(newstate == PLAYER_STATE_DRIVER
    { 
     
        new 
pIscore
        new 
vehicleid
        
vehicleid GetPlayerVehicleID(playerid); 
        
pIscore GetPlayerScore(playerid); 
        if (
GetVehicleModel(vehicleid) == 432 && pIscore PLAYER_LEVEL6//  Rhino
        

            
SendClientMessage(playerid,-1,"Your level is not high enough to drive this vehicle, please kill others to gain score!"); 
            
RemovePlayerFromVehicle(playerid); 

Credits:kareemahmed

That was example of changing vehicle but you need to add another level
Reply
#10

Quote:
Originally Posted by karemmahmed22
Посмотреть сообщение
Under includes:-
You can edit values (scores).
ex: #define PLAYER_LEVEL1 50 instead of #define PLAYER_LEVEL1 10
PHP код:
#define PLAYER_LEVEL1 10 
#define PLAYER_LEVEL2 20
#define PLAYER_LEVEL3 50
#define PLAYER_LEVEL4 70
#define PLAYER_LEVEL5 100 
OnPlayerStateChange:-
PHP код:
    if(newstate == PLAYER_STATE_DRIVER)
    {
    
        new 
pIscore;
        new 
vehicleid;
        
vehicleid GetPlayerVehicleID(playerid);
        
pIscore GetPlayerScore(playerid);
        if (
GetVehicleModel(vehicleid) == 476 && pIscore PLAYER_LEVEL1//  Rustler
        
{
            
SendClientMessage(playerid,-1,"Your level is not high enough to drive this vehicle, please kill others to gain score!");
            
RemovePlayerFromVehicle(playerid);
        }
        
        else if(
GetVehicleModel(vehicleid) == 447 && pIscore PLAYER_LEVEL2//Seasparrow
        
{
            
            
SendClientMessage(playerid,-1,"Your level is not high enough to drive this vehicle, please kill others to gain score!");
            
RemovePlayerFromVehicle(playerid);
        }
        
        else if(
GetVehicleModel(vehicleid) == 593 && pIscore PLAYER_LEVEL3//Dodo
            
        
{
            
            
RemovePlayerFromVehicle(playerid);
            
SendClientMessage(playerid,-1,"Your level is not high enough to drive this vehicle, please kill others to gain score!");
        }
        
        else if(
GetVehicleModel(vehicleid) == 425 && pIscore PLAYER_LEVEL4//Hunter
            
        
{
            
RemovePlayerFromVehicle(playerid);
            
SendClientMessage(playerid,-1,"Your level is not high enough to drive this vehicle, please kill others to gain score!");
        }
        
        else if(
GetVehicleModel(vehicleid) == 520 && pIscore PLAYER_LEVEL5//Hydra
            
        
{
            
RemovePlayerFromVehicle(playerid);
            
SendClientMessage(playerid,-1,"Your level is not high enough to drive this vehicle, please kill others to gain score!");
        }
    
    
    } 
Edit your vehicle ids and scores.

PHP код:
//------------------------------------------------
ReturnPlayerClassName(playerid)
{
    new 
classstr[28] = "Unknown";
    switch(
gClass[playerid])
    {
        case 
0classstr "Support";
        case 
1classstr "Medic";
        case 
2classstr "Scout";
        case 
3classstr "Jetrunner";
        case 
4classstr "Pilot";
        case 
5classstr "Spy";
        case 
6classstr "Terminator";
    }
    return 
classstr;
}
//------------------------------------------------
ShowPlayerClassSelectionDialog(playerid)
{
    new 
dialogstr[556];
    new 
rank GetPlayerRank(playerid);
    
strcat(dialogstr""SAMP_BLUE"Support (Rank 0+)\n");
    
strcat(dialogstr""SAMP_BLUE"Medic (Rank 0+)\n");
    if(
rank >= 1strcat(dialogstr""SAMP_BLUE"Scout (Rank 1+)\n");
    else 
strcat(dialogstr""GREY"Scout (Rank 1+)\n");
    if(
rank >= 3strcat(dialogstr""SAMP_BLUE"Jetrunner (Rank 3+)\n");
    else 
strcat(dialogstr""GREY"Jetrunner (Rank 3+)\n");
    if(
rank >= 5strcat(dialogstr""SAMP_BLUE"Pilot (Rank 5+)\n");
    else 
strcat(dialogstr""GREY"Pilot (Rank 5+)\n");
    if(
rank >= 8strcat(dialogstr""SAMP_BLUE"Spy (Rank 8+)\n");
    else 
strcat(dialogstr""GREY"Spy (Rank 8+)\n");
    if(
rank >= 12strcat(dialogstr""SAMP_BLUE"Terminator (Rank 12+)\n");
    else 
strcat(dialogstr""GREY"Terminator (Rank 12+)\n");
    return 
ShowPlayerDialog(playeridDIALOG_CLASSDIALOG_STYLE_LIST"Class selection (/sc)"dialogstr"Spawn""Last Class");
}
//------------------------------------------------ 
]

this is my class system source
According to this source, one can change this code for me?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)