[Tutorial] Criando Sistema de Driver-By
#1

pawn Код:
#include <a_samp>
pawn Код:
forward SetPlayerPrisao(killerid);
Explicaзгo:

forward SetPlayerPrisao(killerid); Forward usada na callback(Public) SetPlayerPrisao(killerid);

pawn Код:
new bool:Prisao[MAX_PLAYERS];
new String[128];
Explicaзгo:

new bool:Prisao[MAX_PLAYERS]; Tйcnical Boleana(bool) para verificar se o player esta preso ou nгo.

new String[128]; Variavel usada para definimos o tamanho de caracters em um texto.

pawn Код:
public OnPlayerDeath(playerid,killerid)
{
    if(GetPlayerState(killerid) == PLAYER_STATE_DRIVER) {
        new nome[24];
        GetPlayerName(killerid,pname,sizeof(pname));
        format(String, sizeof(String), "{FF0000}%s Foi preso [motivo: Matou com o veiculo ] [Tempo: 1 Minuto ]",nome);
        SendClientMessageToAll(-1, String);
        Prisao[killerid] = true;
        GivePlayerMoney(killerid, -3500);
        SetPlayerPos(killerid, 197.6661, 173.8179, 1003.0233);
        SetPlayerInterior(killerid, 3);
        SetTimerEx("SetPlayerPrisao", 60000, 0, "i", killerid);
    }
    return 1;
}
Explicaзгo:

if(GetPlayerState(killerid) == PLAYER_STATE_DRIVER) Se o player matar com o veiculo, acontecera as linhas abaixo.

new nome[24]; Numero de caracters do nome do player.

GetPlayerName(killerid,pname,sizeof(pname)); Pegara o nome do player.

format(String, sizeof(String), "{FF0000}%s Foi preso [motivo: Matou com o veiculo ] [Tempo: 1 Minuto ]",nome); Ira formata a menssagem, Nome = Exibira o nome do player

SendClientMessageToAll(-1, String); Mandara a menssagem a todos os players, Setara a cor da menssgem, Definir o numero de caracters da mensagem.

Prisao[killerid] = true; Setara a prisao do player para true ou 1(Um), ou seja o player sera preso.

GivePlayerMoney(killerid, -3500); O player perdera -3500 de dinheiro.

SetPlayerPos(killerid, 197.6661, 173.8179, 1003.0233); O player sera setado para a Posiзгo ''197.6661, 173.8179, 1003.0233''

SetPlayerInterior(killerid, 3); Sera setado para o interior ''3''

SetTimerEx("SetPlayerPrisao", 60000, 0, "i", killerid); Setara o tempo que o player ficara na prisao '60000' ou seja 60 Segundos = 1 Minuto

pawn Код:
public SetPlayerPrisao(killerid)
{
    new giveplayer[MAX_PLAYER_NAME];
    GetPlayerName(killerid, giveplayer, sizeof(giveplayer));
    SetPlayerInterior(killerid,0);
    SpawnPlayer(killerid);
    Prisao[killerid] = false;
    GameTextForPlayer(killerid, "~w~~h~voce esta ~r~~h~livre!", 1000,1);
    return 1;
}
Explicaзгo:

public SetPlayerPrisao(killerid) Public usada para quando se passar 1 minuto na prisao o player ser souto.

new giveplayer[MAX_PLAYER_NAME]; Criaremos uma variavel para verificar numero de caracters do nome do player.

GetPlayerName(killerid, giveplayer, sizeof(giveplayer)); Verificara o nome do player

SetPlayerInterior(killerid,0); Setara o player para o interior '0' ou seja nenhum.

SpawnPlayer(killerid); Ira dar spawn no player.

Prisao[killerid] = false; Setara a prisao do player para false ou 0(zero)

GameTextForPlayer(killerid, "]] Voce esta livre ]]", 1000,1); Mandara um Game Text para o player dizendo que ele esta livre.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp("/kkk", cmdtext, true)) {
        if(Prisao[playerid] == true)
            return SendClientMessage(playerid, -1, "Vocк nгo pode digitar nenhum comando enquanto estiver preso!");
        SendClientMessage(playerid, -1, "Kakakakakaka...");
        return 1;
    }
    return 0;
}
Explicaзгo:
f(Prisao[playerid] == true)
return SendClientMessage(playerid, -1, "Vocк nгo pode digitar nenhum comando enquanto estiver preso!");
ira verificar se o player esta preso, se caso ele estiver mandara a seguinte mensagem "Vocк nгo pode digitar nenhum comando enquanto estiver preso!" se nгo estiver o comando funcionara perfeitamente.
Reply
#2

Otimo tutorial parabens continue assim agora meu servidor tem system de db era tudo que estava procura
Reply
#3

Quote:
Originally Posted by Victor_Souz4
Посмотреть сообщение
Otimo tutorial parabens continue assim agora meu servidor tem system de db era tudo que estava procura
thank you .
Reply
#4

Parabens pelo Tuto cara continue assim
Reply
#5

Tem uma falha grave.

Relogou, tб livre. : D
Reply
#6

Quote:
Originally Posted by Viniborn
Посмотреть сообщение
Tem uma falha grave.

Relogou, tб livre. : D
Concertado,
Reply
#7

legal tutorial.
Reply
#8

Bom mas devia ter identado
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(Prisao[playerid] == true)
return SendClientMessage(playerid, -1, "Vocк nгo pode digitar nenhum comando enquanto estiver preso!");
if (!strcmp("/kkk", cmdtext, true))
{
SendClientMessage(playerid, -1, "Kakakakakaka...");
return 1;
}
return 0;
}
Assim fica mais facil no topo da public nгo podendo usar nenhum comando
Reply
#9

melhor ...
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(Prisao[playerid] == true)
        return SendClientMessage(playerid, -1, "Vocк nгo pode digitar nenhum comando enquanto estiver preso!");
    //
    // OUTROS COMANDOS AKIEEEE
    //
    if (!strcmp("/kkk", cmdtext, true))
    {
        SendClientMessage(playerid, -1, "Kakakakakaka...");
        return 1;
    }
    return 0;
}
Reply
#10

Quote:
Originally Posted by [O.z]Caroline
Посмотреть сообщение
legal tutorial.
bigado
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)