Warrant
#1

So, i made a warrant system for my server. If player doesn't have a driving license and he drives a vehicle, he'll get a wanted level:

pawn Код:
if (IsDoorVehicle(vehicleid))
            {
                switch (Player[playerid][VehicleLicense])
                {
                    case 0:
                    {
                        SCM(playerid, COLOR_LIGHTRED, "* Commited a crime: (Vehicle theft | Driving without a valid driving license) - Your wanted level has been increased.");
                        SetPlayerWantedLevelEx(playerid, GetPlayerWantedLevel(playerid)+1);

                        format(string,sizeof(string),"* [Law Enforcement Radio]: Vehicle theft without license (%s) by %s (%d) - Zone: %s",  ReturnVehicleName(vehicleid), ReturnPlayerName(playerid), playerid, zone);
                        SendMessageToCops(string);
                    }
                    case 1:
                    {
                        SCM(playerid, COLOR_LIGHTRED, "* Commited a crime: (Vehicle Theft) - Your wanted level has been increased.");
                        SetPlayerWantedLevelEx(playerid, GetPlayerWantedLevel(playerid)+1);

                        format(string,sizeof(string),"* [Law Enforcement Radio]: Vehicle theft (%s) by %s (%d) - Zone: %s",  ReturnVehicleName(vehicleid), ReturnPlayerName(playerid), playerid, zone);
                        SendMessageToCops(string);
                    }
                }
                SetPVarInt(playerid,"WarrantTime",GetTickCount()+60000);
                if(GetPVarInt(playerid,"WarrantTime")>GetTickCount()) return 0;
                                }
Everything works, but as you can see, i set pvars to prevent adding a wanted level everytime a player exits/enters the vehicle.

It's a 1 minute cooldown, means if the player got already the wanted level for driving without license and he tries to re-enter another vehicle in less than 1 minute, he'll not get wanted level again.

But doesn't work, what's wrong? Probably added in wrong place the pvars?
Reply
#2

Come on... Saying it doesn't work, is just plain vague... What does it actually do, and what do you expect it to do instead?

I also mentioned the pVar usage a few days back, but got ignored. Unless it's going to share information across scripts, it's likely a waste.
Reply
#3

It doesn't work means if i enter/exist a vehicle in a time less than 1 minute, i'll still get the wanted level.

Pvars are useful for me. I use them alot in my gamemode, they're better than normal timers.
Reply
#4

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
Pvars are useful for me. I use them alot in my gamemode, they're better than normal timers.
wtf lmao
Reply
#5

Whats so funny?
Reply
#6

The time check must be above the code, its meaningless under

PHP код:
                if(GetPVarInt(playerid,"WarrantTime")>GetTickCount()) return 0;
switch (
Player[playerid][VehicleLicense])
                {
                    case 
0:
                    {
                        
SCM(playeridCOLOR_LIGHTRED"* Commited a crime: (Vehicle theft | Driving without a valid driving license) - Your wanted level has been increased.");
                        
SetPlayerWantedLevelEx(playeridGetPlayerWantedLevel(playerid)+1);
                        
format(string,sizeof(string),"* [Law Enforcement Radio]: Vehicle theft without license (%s) by %s (%d) - Zone: %s",  ReturnVehicleName(vehicleid), ReturnPlayerName(playerid), playeridzone);
                        
SendMessageToCops(string);
SetPVarInt(playerid,"WarrantTime",GetTickCount()+60000);
                    }
                    case 
1:
                    {
                        
SCM(playeridCOLOR_LIGHTRED"* Commited a crime: (Vehicle Theft) - Your wanted level has been increased.");
                        
SetPlayerWantedLevelEx(playeridGetPlayerWantedLevel(playerid)+1);
                        
format(string,sizeof(string),"* [Law Enforcement Radio]: Vehicle theft (%s) by %s (%d) - Zone: %s",  ReturnVehicleName(vehicleid), ReturnPlayerName(playerid), playeridzone);
                        
SendMessageToCops(string);
SetPVarInt(playerid,"WarrantTime",GetTickCount()+60000);
                    }
                } 
Reply
#7

Quote:

error 002: only a single statement (or expression) can follow each "case"

This.
Reply
#8

Line?
Reply
#9

Every line where i placed the "GetPvarInt" code.
Reply
#10

I tried this code and its compiling fine with no errors
PHP код:
    if(GetPVarInt(playerid,"WarrantTime")>GetTickCount()) return 0
    switch(
Player[playerid][VehicleLicense]) 
    { 
        case 
0
        { 
            
SCM(playeridCOLOR_LIGHTRED"* Commited a crime: (Vehicle theft | Driving without a valid driving license) - Your wanted level has been increased."); 
            
SetPlayerWantedLevelEx(playeridGetPlayerWantedLevel(playerid)+1); 
            
format(string,sizeof(string),"* [Law Enforcement Radio]: Vehicle theft without license (%s) by %s (%d) - Zone: %s",  ReturnVehicleName(vehicleid), ReturnPlayerName(playerid), playeridzone); 
            
SendMessageToCops(string); 
            
SetPVarInt(playerid,"WarrantTime",GetTickCount()+60000); 
        } 
        case 
1
        { 
            
SCM(playeridCOLOR_LIGHTRED"* Commited a crime: (Vehicle Theft) - Your wanted level has been increased."); 
            
SetPlayerWantedLevelEx(playeridGetPlayerWantedLevel(playerid)+1); 
            
format(string,sizeof(string),"* [Law Enforcement Radio]: Vehicle theft (%s) by %s (%d) - Zone: %s",  ReturnVehicleName(vehicleid), ReturnPlayerName(playerid), playeridzone); 
            
SendMessageToCops(string); 
            
SetPVarInt(playerid,"WarrantTime",GetTickCount()+60000); 
        } 
    } 
Show whole code
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)