CMD:duel (playerid, params[])
{
new giveid;
if (gIsDuelActive == 1) return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"A duel is already active!");
if (PlayerInfo[playerid][IsInDuel] == 1) return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"You are already in a duel!");
if (sscanf(params, "u", giveid)) return SendClientMessage(playerid, -1, ""RED"USAGE: "WHITE"/duel [ID]");
if (giveid == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"Invalid player ID!");
if (PlayerInfo[giveid][NoDuelRequests] == 1) return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"The player has duel requests disabled!");
if (PlayerInfo[giveid][IsWaiting] == 1) return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"The player is waiting for another duel!");
ShowPlayerDialog(playerid, DIALOG_CHOOSE_WEAPON, DIALOG_STYLE_LIST, ""PREMIUM"Choose weapon for duel:", "• Desert Eagle\n• Sawn Off Shotgun\n• Combat Shotgun\n• Micro SMG/Uzi\n• M4\n• Shotgun", "Select", "Cancel");
PlayerInfo[playerid][IsWaiting] = 1;
PlayerInfo[playerid][DuelTargetID] = giveid;
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == DIALOG_CHOOSE_WEAPON)
{
if (!response) return 1;
if (response)
{
switch (listitem)
{
case 0:
{
gCurrentDuelWeaponID = 24;
format(str, sizeof(str), ""RED"[DUEL] "LIGHTBLUE"%s(%d) has challenged you for a duel with "PREMIUM"Desert Eagle"LIGHTBLUE"! (Use /accept or /deny)", GetName(playerid), playerid);
SendClientMessage(PlayerInfo[playerid][DuelTargetID], -1, str);
PlayerInfo[PlayerInfo[playerid][DuelTargetID]][IsWaiting] = 1;
}
case 1:
{
gCurrentDuelWeaponID = 26;
format(str, sizeof(str), ""RED"[DUEL] "LIGHTBLUE"%s(%d) has challenged you for a duel with "PREMIUM"Sawn Off Shotgun"LIGHTBLUE"! (Use /accept or /deny)", GetName(playerid), playerid);
SendClientMessage(PlayerInfo[playerid][DuelTargetID], -1, str);
PlayerInfo[PlayerInfo[playerid][DuelTargetID]][IsWaiting] = 1;
}
case 2:
{
gCurrentDuelWeaponID = 27;
format(str, sizeof(str), ""RED"[DUEL] "LIGHTBLUE"%s(%d) has challenged you for a duel with "PREMIUM"Combat Shotgun"LIGHTBLUE"! (Use /accept or /deny)", GetName(playerid), playerid);
SendClientMessage(PlayerInfo[playerid][DuelTargetID], -1, str);
PlayerInfo[PlayerInfo[playerid][DuelTargetID]][IsWaiting] = 1;
}
case 3:
{
gCurrentDuelWeaponID = 28;
format(str, sizeof(str), ""RED"[DUEL] "LIGHTBLUE"%s(%d) has challenged you for a duel with "PREMIUM"Micro SMG/Uzi"LIGHTBLUE"! (Use /accept or /deny)", GetName(playerid), playerid);
SendClientMessage(PlayerInfo[playerid][DuelTargetID], -1, str);
PlayerInfo[PlayerInfo[playerid][DuelTargetID]][IsWaiting] = 1;
}
case 4:
{
gCurrentDuelWeaponID = 31;
format(str, sizeof(str), ""RED"[DUEL] "LIGHTBLUE"%s(%d) has challenged you for a duel with "PREMIUM"M4"LIGHTBLUE"! (Use /accept or /deny)", GetName(playerid), playerid);
SendClientMessage(PlayerInfo[playerid][DuelTargetID], -1, str);
PlayerInfo[PlayerInfo[playerid][DuelTargetID]][IsWaiting] = 1;
}
case 5:
{
gCurrentDuelWeaponID = 25;
format(str, sizeof(str), ""RED"[DUEL] "LIGHTBLUE"%s(%d) has challenged you for a duel with "PREMIUM"Shotgun"LIGHTBLUE"! (Use /accept or /deny)", GetName(playerid), playerid);
SendClientMessage(PlayerInfo[playerid][DuelTargetID], -1, str);
PlayerInfo[PlayerInfo[playerid][DuelTargetID]][IsWaiting] = 1;
}
}
}
}
return 1;
}
Why are you using "ud" for giveid instead of "u"?
And where is the new str[length]? |
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_CHOOSE_WEAPON:
{
if !response *then return true;
switch(listitem)
{
case 0: gCurrentDuelWeaponID = 24;
case 1..3: gCurrentDuelWeaponID = 25+listitem;
case 4: gCurrentDuelWeaponID = 31;
case 5: gCurrentDuelWeaponID = 25;
}
format(str, sizeof(str), ""RED"[DUEL] "LIGHTBLUE"%s(%d) has challenged you for a duel with "PREMIUM"%s"LIGHTBLUE"! (Use /accept or /deny)", GetName(playerid), playerid, getWeaponName(.id=gCurrentDuelWeaponID));
SendClientMessage(PlayerInfo[playerid][DuelTargetID], -1, str);
PlayerInfo[PlayerInfo[playerid][DuelTargetID]][IsWaiting] = 1;
}
}
return true;
}
getWeaponName(id)
{
new str[15];
switch(id)
{
case 24: str = "Desert Eagle";
case 25: str = "Shotgun";
case 26: str = "Sawn Off";
case 27: str = "Combat Shotgun";
case 28: str = "Micro SMG/UZI";
case 31: str = "M4";
}
return str;
}
CMD:duel (playerid, params[])
{
if gIsDuelActive == 1 *then return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"A duel is already active!");
if PlayerInfo[playerid][IsInDuel] == 1 *then return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"You are already in a duel!");
if sscanf(params, "u", params[0]) *then return SendClientMessage(playerid, -1, ""RED"USAGE: "WHITE"/duel [ID]");
if params[0] == INVALID_PLAYER_ID *then return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"Invalid player ID!");
if PlayerInfo[params[0]][NoDuelRequests] == 1 *then return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"The player has duel requests disabled!");
if PlayerInfo[params[0]][IsWaiting] == 1 *then return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"The player is waiting for another duel!");
PlayerInfo[playerid][IsWaiting] = 1;
PlayerInfo[playerid][DuelTargetID] = params[0];
ShowPlayerDialog(playerid, DIALOG_CHOOSE_WEAPON, DIALOG_STYLE_LIST, ""PREMIUM"Choose weapon for duel:", "• Desert Eagle\n• Sawn Off Shotgun\n• Combat Shotgun\n• Micro SMG/Uzi\n• M4\n• Shotgun", "Select", "Cancel");
return 1;
}
format(str, sizeof(str), ""RED"[DUEL] "LIGHTBLUE"%s(%d) has challenged you for a duel with "PREMIUM"%s"LIGHTBLUE"! (Use /accept or /deny)", GetName(playerid), playerid, getWeaponName(.id=gCurrentDuelWeaponID));
SendClientMessage(PlayerInfo[playerid][DuelTargetID], -1, str); // here?
PlayerInfo[PlayerInfo[playerid][DuelTargetID]][IsWaiting] = 1;
Hmm..thanks for that.
But it does not send the message, something is wrong with this, maybe?: pawn Код:
|
CMD:duel (playerid, params[])
{
if(gIsDuelActive == 1) return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"A duel is already active!");
if(PlayerInfo[playerid][IsInDuel]) return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"You are already in a duel!");
new giveid;
if(sscanf(params, "u", giveid)) return SendClientMessage(playerid, -1, ""RED"USAGE: "WHITE"/duel [ID]");
if(giveid == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"Invalid player ID!");
if(PlayerInfo[giveid][NoDuelRequests] == 1) return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"The player has duel requests disabled!");
if(PlayerInfo[giveid][IsWaiting] == 1) return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"The player is waiting for another duel!");
ShowPlayerDialog(playerid, DIALOG_CHOOSE_WEAPON, DIALOG_STYLE_LIST, ""PREMIUM"Choose weapon for duel:", "• Desert Eagle\n• Sawn Off Shotgun\n• Combat Shotgun\n• Micro SMG/Uzi\n• M4\n• Shotgun", "Select", "Cancel");
PlayerInfo[playerid][IsWaiting] = 1;
PlayerInfo[playerid][DuelTargetID] = giveid;
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_CHOOSE_WEAPON)
{
if(response)
{
new weapon, duelstr[128], gunname[32];
switch(listitem)
{
case 0: weapon = 24;
case 1: weapon = 26;
case 2: weapon = 27;
case 3: weapon = 28;
case 4: weapon = 31;
case 5: weapon = 25;
}
gCurrentDuelWeaponID = weapon;
//I'm not sure if you're meant to be using a global variable for this, so I'll leave it for you to decide.
GetWeaponName(weapon, gunname, sizeof(gunname));
format(duelstr, sizeof(duelstr), ""RED"[DUEL] "LIGHTBLUE"%s(%d) has challenged you to a duel with a "PREMIUM"%s"LIGHTBLUE"! (Use /accept or /deny)", GetName(playerid), playerid, gunname);
SendClientMessage(PlayerInfo[playerid][DuelTargetID], -1, duelstr);
PlayerInfo[PlayerInfo[playerid][DuelTargetID]][IsWaiting] = 1;
}
return 1;
}
return 0; //OnDialogResponse should return 0, not 1.
}