Would this work?
#1

Well, I can't port forward, so I can't exactly test this code... Therefore, i'm wondering if someone could tell me if this code would work; The objective: A classic hitman system - /contract, /givehit -> Kill.

pawn Код:
COMMAND:contract(playerid, params[])
{
    new user, amount, contractreason[128], string[128];
    if(sscanf(params, "uis[128]", user, amount, contractreason))
        return SendClientMessage(playerid, grey, "[USAGE] /Contract <Player ID> <Contract Amount> <Reason>");
    if(PVar[playerid][pFaction] == 2)
        return SendClientMessage(playerid, red, "ERROR: {FFFFFF}Hitmen cannot place contracts.");
    if(amount < 3000)
        return SendClientMessage(playerid, red, "ERROR: {FFFFFF}Amount has to be higher than $3,000!");
    if(GetPlayerMoney(playerid) < amount)
        return SendClientMessage(playerid, red, "ERROR: {FFFFFF}You do not have enough money to place this contract.");
    PVar[user][ContractAmount] += amount;
    format(PVar[user][ContractedBy], MAX_PLAYER_NAME, "%s", pName(playerid));
    format(PVar[user][ContractReason], 128, contractreason);
    format(string, sizeof(string), "<Contract> %s has placed a contract on %s; Reason: %s", pName(playerid), pName(user), contractreason);
    printf(string);
    GivePlayerMoney(playerid, -amount);
    return 1;
}

COMMAND:givehit(playerid, params[])
{
    new user, hitman, string[128];
    if(PVar[playerid][pFaction] == 2)
    {
        if(sscanf(params, "uu", user, hitman))
            return SendClientMessage(playerid, grey, "[USAGE] /GiveHit <Player ID> <Hitman ID>");
        ChasingHit[hitman] = user;
        ChasingHit[user] = hitman;
        format(string, sizeof(string), "{0FA0D1}Server: {FFFFFF}You have been assigned to kill {FF003F}%s{FFFFFF}.", pName(user));
        SendClientMessage(hitman, white, string);
    }
    return 1;
}
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new string[128];
    if(PVar[playerid][ContractAmount] != 0)
    {
        if(PVar[killerid][pFaction] == 2)
        {
            if(ChasingHit[killerid] == playerid)
            {
                GivePlayerMoney(killerid, PVar[playerid][ContractAmount]/2);
                GivePlayerMoney(playerid, -PVar[playerid][ContractAmount]/2);
                PVar[playerid][ContractAmount] = 0;
                format(PVar[playerid][ContractedBy], MAX_PLAYER_NAME, "Nobody");
                ChasingHit[killerid] = 1000;
                format(string, sizeof(string), "{0FA0D1}Server: {FFFFFF}You have been killed by a {FF003F}Hitman Agency {FFFFFF}member. You have lost {36B816}$%d{FFFFFF}!");
                SendClientMessage(playerid, white, string);
                format(string, sizeof(string), "{0FA0D1}Server: {FFFFFF}You have completed your {FF003F}contract{FFFFFF}. You have gained {36B816}$%d{FFFFFF}!");
                SendClientMessage(killerid, white, string);
            }
            if(ChasingHit[playerid] == killerid)
            {
                if(PVar[killerid][pFaction] == 2)
                {
                     GivePlayerMoney(playerid, -PVar[killerid][ContractAmount]/2);
                     GivePlayerMoney(killerid, PVar[killerid][ContractAmount]/2);
                     format(PVar[killerid][ContractedBy], MAX_PLAYER_NAME, "Nobody");
                     PVar[killerid][ContractAmount] = 0;
                     ChasingHit[playerid] = 1000;
                     format(string, sizeof(string), "{0FA0D1}Server: {FFFFFF}You have killed a {FF003F}Hitman Agency {FFFFFF}member. You have gained {36B816}$%d{FFFFFF}!");
                     SendClientMessage(killerid, white, string);
                     format(string, sizeof(string), "{0FA0D1}Server: {FFFFFF}You have failed your {FF003F}contract{FFFFFF}. You have lost {36B816}$%d{FFFFFF}!");
                     SendClientMessage(playerid, white, string);
                }
            }
        }
    }
    PVar[killerid][pKills] += 1;
    PVar[playerid][pDeaths] += 1;
    return 1;
}
I also created a test command, which showed my contract value, reason, and the contractee, which seems to be working.

pawn Код:
COMMAND:test(playerid, params[])
{
    new string[128];
    format(string, sizeof(string), "Contract Amount: $%d | Contracted By: %s | Reason: %s", PVar[playerid][ContractAmount], PVar[playerid][ContractedBy], PVar[playerid][ContractReason]);
    SendClientMessage(playerid, white, string);
    return 1;
}
Reply
#2

So... What now?
Reply
#3

Quote:
Originally Posted by maramizo
Посмотреть сообщение
So... What now?
Basically I need someone to test it, but as I can't port forward, I cannot do it myself.
Reply
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
127.0.0.1 <- Localhost, no need for any port forwarding at all.
Eh, this system requires two players to test though. Notice the part under OnPlayerDeath.
Reply
#5

You don't need portfoward... Just run the server and add on samp the follwing ip: 127.0.0.1:7777

This will show you your server....

P.S: Only you can connect to this server....
PP.S: You can download sandiebox, this program will allow you to open 2 gta's so you can connect 2 players to the server(yourself to times) and tezt the cmds you cant test with only 1 player!
Reply
#6

Quote:
Originally Posted by ricardo178
Посмотреть сообщение
PP.S: You can download sandiebox, this program will allow you to open 2 gta's so you can connect 2 players to the server(yourself to times) and tezt the cmds you cant test with only 1 player!
Hmm, this is rather interesting, thank you!
Reply
#7

Quote:
Originally Posted by ******
Посмотреть сообщение
Also port forwarding often doesn't apply on a LAN, so if you have two computers they should be able to connect to each other.
Yeah, I know this. Sadly, I only have one computer. Thank you though.
Reply
#8

Quote:
Originally Posted by ricardo178
Посмотреть сообщение
PP.S: You can download sandiebox, this program will allow you to open 2 gta's so you can connect 2 players to the server(yourself to times) and tezt the cmds you cant test with only 1 player!
Can you give the download link please?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)