setting to player 0 -
alexanderjb918 - 05.06.2016
Код:
COMMAND:locations(playerid, params[])
{
format(gVar3000, sizeof(gVar3000), "%s", EOS);
for(new i = 0; i != sizeof(Locs); i++)
{
if(isnull(gVar3000)) {
format(gVar3000, sizeof(gVar3000), "%s", Locs[i][locName]);
} else {
format(gVar3000, sizeof(gVar3000), "%s\n%s", gVar3000, Locs[i][locName]);
}
}
ShowPlayerDialog(playerid, DIALOG_LOCATIONS, DIALOG_STYLE_LIST, "{FF9900}Locations", gVar3000, "Mark", "Cancel");
return format(gVar3000, sizeof(gVar3000), "%s", EOS);
}
Any ideas why its setting to player 0.
Re: setting to player 0 -
SickAttack - 05.06.2016
What do you exactly mean?
Re: setting to player 0 -
alexanderjb918 - 05.06.2016
For example I type locations /locations and select a location it says I have a checkpoint but it does not show and it only shows for the ID 0 player?
Re: setting to player 0 -
Skimmer - 05.06.2016
Show us your onDialogResponse content.
Re: setting to player 0 -
alexanderjb918 - 05.06.2016
case DIALOG_LOCATIONS:
{
if(response)
{
new message[100];
format(message, 100, "You have successfully marked {FF6347}%s{FFFFFF} on your map.",Locs[listitem][locName]);
SendClientMessage(playerid, -1, message);
SendClientMessage(playerid, -1, "In order to remove the checkpoint, type {FF6347}/killcheckpoint{FFFFFF}.");
PlayerInfo[playerid][pLocations] = SetPlayerRaceCheckpoint(PlayerInfo[playerid][pShowtheway_ID], 2, Locs[listitem][locX], Locs[listitem][locY], Locs[listitem][locZ], 0, 0, 0, 3.0);
}
}
Re: setting to player 0 -
alexanderjb918 - 05.06.2016
and this command works using the same dialog
COMMAND

howtheway(playerid, params[])
{
if(PlayerInfo[playerid][pAdminlevel] == 0 && PlayerInfo[playerid][pModLevel] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You must be Moderator to use this command.");
new user;
if(sscanf(params, "u", user)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /showtheway [playerid]");
if(user == INVALID_PLAYER_ID) sscanf(params, "i", user);
if(user > MAX_PLAYERS) user = DeterminePlayerID(user);
if(!IsPlayerConnected(user)) return SendClientMessage(playerid, COLOR_GREY, "Invalid playerID (Submitted playerID is not connected).");
if(IsPlayerNPC(user)) return SendClientMessage(playerid, COLOR_GREY, "Invalid playerID (Submitted playerID points at NPC).");
PlayerInfo[playerid][pShowtheway_ID] = user;
format(gVar3000, sizeof(gVar3000), "%s", EOS);
for(new i = 0; i != sizeof(Locs); i++)
{
if(isnull(gVar3000)) format(gVar3000, sizeof(gVar3000), "%s", Locs[i][locName]);
else format(gVar3000, sizeof(gVar3000), "%s\n%s", gVar3000, Locs[i][locName]);
}
ShowPlayerDialog(playerid, DIALOG_SHOW_LOCATIONS, DIALOG_STYLE_LIST, "{FF9900}Locations", gVar3000, "Mark", "Cancel");
return format(gVar3000, sizeof(gVar3000), "%s", EOS);
}
Re: setting to player 0 -
Skimmer - 05.06.2016
Probably this
PlayerInfo[playerid][pShowtheway_ID] contains the value 0 and that's why only playerid 0 can see the checkpoint, because you're setting for him.
https://sampwiki.blast.hk/wiki/SetPlayerRaceCheckpoint
Re: setting to player 0 -
Konstantinos - 05.06.2016
What Skimmer says is correct and you should use
playerid as first parameter instead.
SetPlayerRaceCheckpoint also does not return any value so do:
pawn Код:
PlayerInfo[playerid][pLocations] = listitem;
EDIT:
Okay, you set the "user" to PlayerInfo[playerid][pShowtheway_ID] but some of your custom functions returns 0 if there is no correct player? Anyway, all those checks seems pointless since "u" specifier takes ID or part of name.
All you have to do is:
pawn Код:
if(sscanf(params, "u", user)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /showtheway [playerid]");
if(user == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY, "Invalid playerID (Submitted playerID is not connected).");
if(IsPlayerNPC(user)) return SendClientMessage(playerid, COLOR_GREY, "Invalid playerID (Submitted playerID points at NPC).");
and reset PlayerInfo[playerid][pShowtheway_ID] to INVALID_PLAYER_ID on connect/disconnect and where needed.
The messages in dialog response are a bit misleading as the admin "shows" the way to a player but the admin gets the message about the marked checkpoint and how to remove it.
As you used but without storing to anything
pawn Код:
SetPlayerRaceCheckpoint(PlayerInfo[playerid][pShowtheway_ID], 2, Locs[listitem][locX], Locs[listitem][locY], Locs[listitem][locZ], 0, 0, 0, 3.0);
and depending on whether the location should be saved to the player given or the admin, change the following:
pawn Код:
// admin's
PlayerInfo[playerid][pLocations] = listitem;
// given player's
PlayerInfo[PlayerInfo[playerid][pShowtheway_ID]][pLocations] = listitem;
Sorry it took me so long to reply.
EDIT 2: Since you have 2 commands, you will need to do the following. In the dialog response if PlayerInfo[playerid][pShowtheway_ID] is equal to INVALID_PLAYER_ID and set the checkpoint+messages to playerid. Otherwise, set them for PlayerInfo[playerid][pShowtheway_ID].
Re: setting to player 0 -
alexanderjb918 - 05.06.2016
The second command works fine tho if i show the playerid it.
Re: setting to player 0 -
alexanderjb918 - 05.06.2016
I think you guys got the wrong idea

the second command works PERFECT if i show the playerid the location I want to make it so he can just type /locations and select a location himself it works but the checkpoint go's to ID 0.