Random Help
#1

How To Use Random Checkpoint ? Player Go To 1 Of Random Checkpoints Give Money ?
This is Code :
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (newkeys == KEY_WALK)
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, 1230.6826,-807.1774,1084.0078))
        {
            kakhJob[playerid] = 1;
            new name[MAX_PLAYER_NAME], string[120];
            GetPlayerName(playerid, name, sizeof(name));
            format(string, sizeof(string), "{00FFFF}[Shoghl] {ADD8E6}Is Robing.. Player : %s", name );
            SendClientMessageToAll(COLOR_YELLOW, string);
            SetPlayerCheckpoint(playerid,-484.5330,-1480.2612,13.9457,10);
            SendClientMessage(playerid,COLOR_LIGHTBLUE,"[Shoghl] {FFFF00}NiCe!");
			new rand,Float:X, Float:Y, Float:Z;
        	rand = random(4);
 	 		switch(rand)
        	{
            case 0:{X = -488.9691;Y = -1454.4095;Z = 13.6985;}
            case 1:{X = -491.1559;Y = -1590.0781;Z = 6.0986;}
            case 2:{X = 2141.2703;Y = -1611.0664;Z = 13.8660;}
            case 3:{X = 1092.9705;Y = -1093.6687;Z = 25.5253;}
        	}
        	SetPlayerCheckpoint(playerid, X, Y, Z, 5.0);
            return 1;
        }
    } else {
	if(IsPlayerInRangeOfPoint(playerid, 3.0, 1230.6826,-807.1774,1084.0078))
        SendClientMessage(playerid, COLOR_RED, "[Dozdi] {FFFF00}Use Alt For Rob!");
	}
Reply
#2

That code doesn't work? Minus the terrible readability, it looks like it should work properly. You got any errors?

#E: Oh, sorry, didn't understand at first.

pawn Код:
//somewhere higher
new currentCheckpoint[MAX_PLAYER char];

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (newkeys == KEY_WALK)
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, 1230.6826,-807.1774,1084.0078))
        {
            kakhJob[playerid] = 1;
            new name[MAX_PLAYER_NAME], string[120];
            GetPlayerName(playerid, name, sizeof(name));
            format(string, sizeof(string), "{00FFFF}[Shoghl] {ADD8E6}Is Robing.. Player : %s", name );
            SendClientMessageToAll(COLOR_YELLOW, string);
            SetPlayerCheckpoint(playerid,-484.5330,-1480.2612,13.9457,10);
            SendClientMessage(playerid,COLOR_LIGHTBLUE,"[Shoghl] {FFFF00}NiCe!");
            new rand,Float:X, Float:Y, Float:Z;
            rand = random(5) + 1;
            switch(rand)
            {
                case 1: {X = -488.9691;Y = -1454.4095;Z = 13.6985;}
                case 2: {X = -491.1559;Y = -1590.0781;Z = 6.0986;}
                case 3: {X = 2141.2703;Y = -1611.0664;Z = 13.8660;}
                case 4: {X = 1092.9705;Y = -1093.6687;Z = 25.5253;}
            }
            currentCheckpoint{playerid} = 0;
            SetPlayerCheckpoint(playerid, X, Y, Z, 5.0);
            return 1;
        }
    }
    else {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, 1230.6826,-807.1774,1084.0078)) SendClientMessage(playerid, COLOR_RED, "[Dozdi] {FFFF00}Use Alt For Rob!");
    }
}

//Somewhere else
public OnPlayerEnterCheckpoint(playerid)
{
    if(currentCheckpoint{playerid}) {
        //Yay
        GivePlayerMoney(playerid, 100000);
        currentCheckpoint{playerid} = 0;
    }
    return 1;
}
Reply
#3

Код:
new cp1[MAX_PLAYERS];
cp1[playerid] = 1;
SetPlayerCheckpoint(playerid, X, Y, Z, 5.0);
then

Код:
public OnPlayerEnterCheckpoint(playerid)
{
if(cp1[playerid] == 1)
{
GivePlayerMoney(playerid, 4000);
cp1[playerid] = 0;
}
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)