• Welcome to Vice City Multiplayer.
 

"if" is not working.

Started by Jancis_LV, February 01, 2010, 09:10:56 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Jancis_LV



Help me someone something aren't working, when someone dies when is on "Duel", than nothing else happens.
This is on OnPlayerDeath
if(PlayerInfo[playerid][Duel] == 1)  DuelLos(playerid,1);

public IncPlayerDuelWons(playerid,Amount)
{
format(file, sizeof(file), USERS_FILE, gPlayers[playerid]);
new duelw; duelw = dini_Int(file, "DuelWons");
dini_IntSet(file, "DuelWons", duelw +Amount);
}

public IncPlayerDuelLoses(playerid,Amount)
{
format(file, sizeof(file), USERS_FILE, gPlayers[playerid]);
new duell; duell = dini_Int(file, "DuelLoses");
dini_IntSet(file, "DuelLoses", duell +Amount);
}

public DuelWon(playerid,Amount)
{
format(file, sizeof(file), USERS_FILE, gPlayers[playerid]);
dini_IntSet(file, "Duel", 0);
new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    SendClientMessageToAll(ORANGE,"%s won in duel", name);
    IncPlayerDuelWons(playerid,1);
SetPlayerPos(playerid, -731.411499,-1526.219848,12.526686,120,0);
}

public DuelLos(playerid,Amount)
{
format(file, sizeof(file), USERS_FILE, gPlayers[playerid]);
dini_IntSet(file, "Duel", 0);
new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    SendClientMessageToAll(ORANGE,"%s lost in duel", name);
    IncPlayerDuelLoses(playerid,1);
}


Thanks.
Latvian Vice City server
78.84.47.75:5192

thijn

i think it has to be

if(PlayerInfo[playerid]["Duel"] == 1)  DuelLos(playerid,1);

not sure though as i dont script in pawno ;D


Jancis_LV

Than arent possible to compile
Latvian Vice City server
78.84.47.75:5192

JayL


Ettans

The if statement is correct, you should check your DuelLos function.

ClaN_Tai

Note you should always write into your first post what problems compiler says... :)
So my suggestion, try this:

forward IncPlayerDuelWons...
forward IncPlayerDuelLoses
forward DuelWon
forward DuelLos

Remove the forwards...

Keep this:
if(PlayerInfo[playerid][Duel] == 1)  DuelLos(playerid,1);

Exchange the public functions with stocks, as they only change Users
accounts values, important is that you write them under your header.
So first all definitions, includes and then the stocks.
stock IncPlayerDuelWons(playerid,Amount)
{
format(file, sizeof(file), USERS_FILE, gPlayers[playerid]);
new duelw; duelw = dini_Int(file, "DuelWons");
dini_IntSet(file, "DuelWons", duelw +Amount);
}

stock IncPlayerDuelLoses(playerid,Amount)
{
format(file, sizeof(file), USERS_FILE, gPlayers[playerid]);
new duell; duell = dini_Int(file, "DuelLoses");
dini_IntSet(file, "DuelLoses", duell +Amount);
}
stock DuelWon(playerid,Amount)
{
format(file, sizeof(file), USERS_FILE, gPlayers[playerid]);
dini_IntSet(file, "Duel", 0);
new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    SendClientMessageToAll(ORANGE,"%s won in duel", name);
    IncPlayerDuelWons(playerid,1);
SetPlayerPos(playerid, -731.411499,-1526.219848,12.526686,120,0);
}

stock DuelLos(playerid,Amount)
{
format(file, sizeof(file), USERS_FILE, gPlayers[playerid]);
dini_IntSet(file, "Duel", 0);
new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    SendClientMessageToAll(ORANGE,"%s lost in duel", name);
    IncPlayerDuelLoses(playerid,1);
}


If it still don't work you need to give me more informations about this "USER_FILE" and the return of gPlayers[playerid].

Cheers, Tai

ClaN_Tai

Alert: I also seen another thing that is impossible to work!

SendClientMessageToAll(ORANGE,"%s lost in duel", name);

Will never work!

new string[MAX_STRING];
format(string,sizeof(string),"%s lost in duel",name);
SendClientMessageToAll(ORANGE,string)


As
SendClinetMessageToAll();
has only 2 strings to be set! "color" and "string" :)

Jancis_LV

#7
I use GUPS 1.15 as base

And there is lot of problems:

else if (strcmp(cmd, "!duel", true) == 0) {
if(PlayerInfo[playerid][Logged] != 1) { SendClientMessage(playerid, COLOR_RED, "You need to login first!"); }
else {
SendClientMessage(playerid, COLOR_RED, "Duel commands: !duelj - Joins duel    !duell - Leaves duel if second player does suicide or drown in water");
}
return 1;
}

else if (strcmp(cmd, "!duelj", true) == 0) {

if(PlayerInfo[playerid][Logged] != 1)  {
SendClientMessage(playerid, COLOR_RED, "You need to login first!");
}
  else if (strcmp(PlayerInfo[playerid][Duel], "1", true) == 0)
  {
SendClientMessage(playerid, COLOR_RED, "You already is in duel!");
}

else {
DuelStart(playerid);
if (strcmp(GetFileText("Duel/place.txt"), "0", true) == 0) {
new string[128];
ResetPlayerWeapons(playerid);
SetPlayerWeapon(playerid, 21, 100);
SetPlayerPos(playerid, -349.444946, -1630.163452, 11.637629, 0, 0);
new File:duel=fopen("Duel/place.txt", io_append);
        format(string, 256, "1");
        fwrite(duel, string);
        fclose(duel);
SendClientMessage(playerid, COLOR_ORANGE, "Joining duel");
}
else if (strcmp(GetFileText("Duel/place.txt"), "01", true) == 0) {
new string[128];
ResetPlayerWeapons(playerid);
SetPlayerWeapon(playerid, 21, 100);
SetPlayerPos(playerid, -336.983032, -1646.011840, 11.637629, 180, 0);
new File:duel=fopen("Duel/place.txt", io_append);
        format(string, 256, "1");
        fwrite(duel, string);
        fclose(duel);
SendClientMessage(playerid, COLOR_ORANGE, "Joining duel");
}
else if (strcmp(GetFileText("Duel/place.txt"), "011", true) == 0) {
SendClientMessage(playerid, COLOR_ORANGE, "Duel is full!");
  }
  }
return 1;
}


else if (strcmp(cmd, "!duell", true) == 0) {
if(PlayerInfo[playerid][Duel] == 0)  SendClientMessage(playerid, COLOR_RED, "You aren't in duel!");
else if (strcmp(GetFileText("Duel/place.txt"), "0", false) == 0) SendClientMessage(playerid, COLOR_RED, "Wanted escape?");
else if (strcmp(PlayerInfo[playerid][Duel], "1", true) == 0) DuelWon(playerid);
return 1;
}


stock IncPlayerDuelWons(playerid)
{
format(file, sizeof(file), USERS_FILE, gPlayers[playerid]);
new duelw; duelw = dini_Int(file, "DuelWons");
dini_IntSet(file, "DuelWons", duelw +1);
}

stock IncPlayerDuelLoses(playerid)
{
format(file, sizeof(file), USERS_FILE, gPlayers[playerid]);
new duell; duell = dini_Int(file, "DuelLoses");
dini_IntSet(file, "DuelLoses", duell +1);
}

stock DuelStart(playerid)
{
format(file, sizeof(file), USERS_FILE, gPlayers[playerid]);
dini_IntSet(file, "Duel", 1);
}

stock DuelWon(playerid)
{
format(file, sizeof(file), USERS_FILE, gPlayers[playerid]);
dini_IntSet(file, "Duel", 0);
new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    new string[MAX_STRING];
format(string,sizeof(string),"%s win in duel",name);
SendClientMessageToAll(ORANGE,string);
    IncPlayerDuelWons(playerid);
SetPlayerPos(playerid, -731.411499,-1526.219848,12.526686,120,0);
}



stock DuelLos(playerid)
{
    new string[128];
format(file, sizeof(file), USERS_FILE, gPlayers[playerid]);
dini_IntSet(file, "Duel", 0);
new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    new string2[MAX_STRING];
format(string2,sizeof(string),"%s lost in duel",name);
SendClientMessageToAll(ORANGE,string2);
    IncPlayerDuelLoses(playerid);
    new File:duel=fopen("Duel/place.txt", io_write);
    format(string, 256, "0");
    fwrite(duel, string);
    fclose(duel);
}


Thanks for that people who helped me.
Latvian Vice City server
78.84.47.75:5192