Random Wanted Level +reputation
#1

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER && gTeam[playerid] != TEAM_COP)
    {
        switch(GetVehicleModel(GetPlayerVehicleID(playerid)))
        {
            case 497, 447, 523, 416, 433, 427, 490, 528, 407, 544, 596, 597, 598, 599, 432, 601, 470, 472, 430, 428:
            {
                SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid)+4);
                SendClientMessage(playerid, yellow, "** - VEHICLE CMDS: /lock (Lock the vehicle) - /cw (Send a message to the passengers in your car) - /ej (Eject a player from your vehicle) - /ejall (Eject all passengers from your vehicle)**");
                new string[64];
                format(string, sizeof(string), "- CRIME - Law Enforcement Vehicle Theft - Wanted Level %d ", GetPlayerWantedLevel(playerid));
                SendClientMessage(playerid, red, string);
                for(new i=0;i<MAX_PLAYERS;i++)
                {
                if(!IsPlayerConnected(i))continue;
                if(gTeam[i] == TEAM_COP)
                {
                new copmsg[170];
                new name[MAX_PLAYER_NAME];
                GetPlayerName(playerid, name, sizeof(name));
                format(copmsg, sizeof(copmsg), "- WARNING ALL COPS: Law Enforcement Vehicle Theft By %s (%d)",name,playerid);
                SendClientMessage(i, COLOR_BLUE, copmsg);
                }
                }
            {
    if(newstate == PLAYER_STATE_DRIVER && gTeam[playerid] != TEAM_CIV)
    {
        switch(GetVehicleModel(GetPlayerVehicleID(playerid)))
        {
            case 497, 447, 523, 416, 433, 427, 490, 528, 407, 544, 596, 597, 598, 599, 432, 601, 470, 472, 430, 428:
            {
                SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid)+1);
                SendClientMessage(playerid, yellow, "** - VEHICLE CMDS: /lock (Lock the vehicle) - /cw (Send a message to the passengers in your car) - /ej (Eject a player from your vehicle) - /ejall (Eject all passengers from your vehicle)**");
                new string[64];
                format(string, sizeof(string), "*CRIME* Vehicle Theft - Wanted Level %d", GetPlayerWantedLevel(playerid));
                SendClientMessage(playerid, red, string);
            }
        }
    }


    if(newstate == 2)
	{
        if(LockVeh[playerid] == true)
        {
        GameTextForPlayer(playerid, "~g~Vehicle Unlocked. Use /lock to lock it.", 5000, 5);
        SendClientMessage(playerid,yellow,"Vehicle unlocked.Use /lock to lock it.");
        LockVeh[playerid] = false;
    }
        }
    return 1;
}
Unable To Make The Car Given Below if(newstate == PLAYER_STATE_DRIVER && gTeam[playerid] != TEAM_CIV) That There Will Be 5 Chances Of Getting Wanted Please help Me
Reply
#2

Why not use random() ?
https://sampwiki.blast.hk/wiki/Random
Reply
#3

If you want 5% of chance to get wanted use
PHP код:
if(random(100) == 5//code 
Reply
#4

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
If you want 5% of chance to get wanted use
PHP код:
if(random(100) == 5//code 
This is a 1% chance

PHP код:
if((random(100)+1) <= 5//5% 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)