Author Topic: "if" is not working.  (Read 4360 times)

0 Members and 1 Guest are viewing this topic.

Offline Jancis_LV

  • Street Thug
  • *
  • Posts: 37
    • View Profile
    • Latvian Vice City
"if" is not working.
« on: February 01, 2010, 12:10:56 pm »


Help me someone something aren't working, when someone dies when is on "Duel", than nothing else happens.
This is on OnPlayerDeath
Code: [Select]
if(PlayerInfo[playerid][Duel] == 1)  DuelLos(playerid,1);
Code: [Select]
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

Offline thijn

  • LU testers
  • VC:MP Veteran
  • *
  • Posts: 667
  • Im proud to be pro.
    • View Profile
    • Vice Underdogs
Re: "if" is not working.
« Reply #1 on: February 01, 2010, 04:53:51 pm »
i think it has to be
Code: [Select]
if(PlayerInfo[playerid]["Duel"] == 1)  DuelLos(playerid,1);
not sure though as i dont script in pawno ;D

Offline Jancis_LV

  • Street Thug
  • *
  • Posts: 37
    • View Profile
    • Latvian Vice City
Re: "if" is not working.
« Reply #2 on: February 01, 2010, 06:11:21 pm »
Than arent possible to compile
Latvian Vice City server
78.84.47.75:5192

Offline JayL

  • Street Thug
  • *
  • Posts: 10
    • View Profile
Re: "if" is not working.
« Reply #3 on: February 04, 2010, 06:33:57 pm »
Try adding "return 1;"...

Offline Ettans

  • VC:MP Beta Tester
  • Wiseguy
  • *
  • Posts: 56
    • View Profile
Re: "if" is not working.
« Reply #4 on: February 04, 2010, 08:20:48 pm »
The if statement is correct, you should check your DuelLos function.

Offline ClaN_Tai

  • Street Thug
  • *
  • Posts: 10
    • View Profile
Re: "if" is not working.
« Reply #5 on: February 05, 2010, 09:18:20 pm »
Note you should always write into your first post what problems compiler says... :)
So my suggestion, try this:

Code: [Select]
forward IncPlayerDuelWons...
forward IncPlayerDuelLoses
forward DuelWon
forward DuelLos
Remove the forwards...

Keep this:
Code: [Select]
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.
Code: [Select]
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

Offline ClaN_Tai

  • Street Thug
  • *
  • Posts: 10
    • View Profile
Re: "if" is not working.
« Reply #6 on: February 05, 2010, 09:32:20 pm »
Alert: I also seen another thing that is impossible to work!

Code: [Select]
SendClientMessageToAll(ORANGE,"%s lost in duel", name);
Will never work!

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

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

Offline Jancis_LV

  • Street Thug
  • *
  • Posts: 37
    • View Profile
    • Latvian Vice City
Re: "if" is not working.
« Reply #7 on: February 05, 2010, 09:59:37 pm »
I use GUPS 1.15 as base

And there is lot of problems:

Code: [Select]
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;
}
Code: [Select]
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.
« Last Edit: February 06, 2010, 12:23:01 pm by Jancis_LV »
Latvian Vice City server
78.84.47.75:5192