Little problem with aduty -
RenSoprano - 22.10.2012
Hello I have made a Aduty CMD where it saves Hp, armour and pos. But when I type command in doesn't save me the pos where I was. Here is the CMD
Код:
CMD:aduty(playerid, params[])
{
new Float:PosX, Float:PosY, Float:PosZ, Float:PosA;
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, -1, "This is an admin only command!");
if(PlayerInfo[playerid][pAdminDuty] == 0)
{
SendClientMessageEx(playerid, COLOR_YELLOW, "You are now on administrative duty! Remember to check /reports!");
//SetPlayerName(playerid, PlayerInfo[playerid][pAdminName]);
PlayerInfo[playerid][pAdminDuty] = 1;
GetPlayerPos(playerid, PosX, PosY, PosZ);
GetPlayerFacingAngle(playerid, PosA);
GetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
GetPlayerArmour(playerid, PlayerInfo[playerid][pArmor]);
PlayerInfo[playerid][pInt] = GetPlayerInterior(playerid);
PlayerInfo[playerid][pVW] = GetPlayerVirtualWorld(playerid);
SetPlayerHealth(playerid, 100000);
SetPlayerArmour(playerid, 100000);
SetPlayerColor(playerid, COLOR_TWORANGE);
//SetPlayerSkin(playerid, 294); - Commented by Voltage
new string[128];
format(string, sizeof(string), "Administrator %s is now on Admin Duty! (/report for assistance)", GetPlayerNameEx(playerid));
SendClientMessageToAllEx(COLOR_YELLOW, string);
}
else
{
SendClientMessageEx(playerid, COLOR_RED, "You are now off admin duty!");
//SetPlayerName(playerid, PlayerInfo[playerid][pNormalName]);
PlayerInfo[playerid][pAdminDuty] = 0;
SetPlayerPos(playerid, PosX, PosY, PosZ);
SetPlayerFacingAngle(playerid, PosA);
SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
SetPlayerArmour(playerid, PlayerInfo[playerid][pArmor]);
SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][pVW]);
SetPlayerInterior(playerid, PlayerInfo[playerid][pInt]);
SetPlayerToTeamColor(playerid);
//SetPlayerSkin(playerid, 299); - Commented by Voltage
PlayerInfo[playerid][pAdminDuty] = 0;
new string[128];
format(string, sizeof(string), "Administrator %s is now Off Admin Duty! ( Leave the Admin to Roleplay )", GetPlayerNameEx(playerid));
SendClientMessageToAllEx(COLOR_YELLOW, string);
}
return 1;
}
EDIT: When I retype the CMD it send me to Blueberry at 0.0 0.0 0.0 cordinates
Re: Little problem with aduty -
SuperViper - 22.10.2012
Remove
pawn Код:
new Float:PosX, Float:PosY, Float:PosZ, Float:PosA;
and put
pawn Код:
new Float: playersSavedPosition[MAX_PLAYERS][4];
near the top of your script.
Change
pawn Код:
GetPlayerPos(playerid, PosX, PosY, PosZ);
GetPlayerFacingAngle(playerid, PosA);
to
pawn Код:
GetPlayerPos(playerid, playersSavedPosition[playerid][0], playersSavedPosition[playerid][1], playersSavedPosition[playerid][2]);
GetPlayerFacingAngle(playerid, playersSavedPosition[playerid][3]);
Change
pawn Код:
SetPlayerPos(playerid, PosX, PosY, PosZ);
SetPlayerFacingAngle(playerid, PosA);
to
pawn Код:
SetPlayerPos(playerid, playersSavedPosition[playerid][0], playersSavedPosition[playerid][1], playersSavedPosition[playerid][2]);
SetPlayerFacingAngle(playerid, playersSavedPosition[playerid][3]);
Re: Little problem with aduty -
RenSoprano - 24.10.2012
Doesn't work
Re: Little problem with aduty -
ThePhenix - 24.10.2012
Add it on your PlayerInfo or PlayerData:
PHP код:
Float:XPos,
Float:YPos,
Float:ZPos,
Add it on public OnPlayerConnect:
PHP код:
public OnPlayerConnect(playerid)
{
PlayerInfo[playerid][XPos] = 0.0;
PlayerInfo[playerid][YPos] = 0.0;
PlayerInfo[playerid][ZPos] = 0.0;
//.................................
//..................................
Add it: OnPlayerSpawn:
PHP код:
SetPlayerPos(playerid, PlayerInfo[playerid][XPos], PlayerInfo[playerid][YPos], PlayerInfo[playerid][ZPos]);
//I think you can add something like this, Check if the player is an admin.
Add all that PosX, Posy, PosZ.
Where you go to save the player information.
Re: Little problem with aduty - Jarnu - 24.10.2012
You can try SetPVarFloat:
https://sampwiki.blast.hk/wiki/SetPVarFloat
and GetPVarFloat:
https://sampwiki.blast.hk/wiki/GetPVarFloat
like:
pawn Код:
SetPVarFloat(playerid,"xpost", PosX);
//--- so on.
and then
pawn Код:
SetPlayerPos(playerid, GetPVarFloat(playerid,"xpos"), ... ); //So on.
Re: Little problem with aduty -
RenSoprano - 24.10.2012
Sure will try with floats