/endevent is bugged
#1

Код:
IRP:endevent(playerid, var[])
{
   	if(!Logged(playerid)) return NoLogin(playerid);
	if(Player[playerid][pAdmin] < 4) return NoAuth(playerid);
	if(!EventOn) return SendClientMessage(playerid, COLOR_GRAD2, "There's no current event happening.");
    SendClientMessageToAll(COLOR_LIGHTRED, "** The event has ended.");
	foreach(Player, i)
	{
	    if(Event[i])
	    {
	        GunsBeingRemoved[i] = 1;
		    ResetPlayerWeapons(i);
		    GunsBeingRemoved[playerid] = 1;
		    SetPlayerPos(i, Player[i][pXp], Player[i][pY], Player[i][pZ]);
			SetPlayerInterior(i, Player[i][pInt]);
			SetPlayerVirtualWorld(i, Player[i][pVW]);
			SetPlayerHealth(i, Player[i][pHealth]);
			SetPlayerArmour(i, Player[i][pArmor]);
			for(new w = 0; w < 13; w++)
			{
			    GiveZamoraWeapon(i, Player[i][pWeapon][w], Player[i][pWeaponAmmo][w]);
			}
			Event[i] = 0;
		}
		EventOn = 0; EventLocked = 0;
		ePos[0] = 0; ePos[1] = 0; ePos[2] = 0; EventWep[0] = 0; EventWep[1] = 0; EventWep[2] = 0;
		eInt = 0; eVW = 0; EventHealth = 0; EventArmor = 0;
	}

	return 1;
}
It sets the participants' position to the 0,0,0.
How can I fix it?
Reply
#2

First, hello.

Where you initialized the variable Player[i][pXp] ? Else, by defaut the variable is initialized with 0.0 (for float) and 0 (for char). It's why the player is teleported to position 0.0, 0.0, 0.0

Second, add a condition after for loop.

PHP код:
foreach(new i:Player) if(IsPlayerConnected(i)) 
Else, you can have lot of bugs because "i" is INVALID_PLAYER_ID.

Tell me where your variable above is initialized.
Reply
#3

Can you give me steps please, explain them, not like I understand actually 15% you've wrotten. Tell me what to put where, and what to post here.
Reply
#4

Where variable PlayerInfo[...][pXp], [pY], [pZ] has initialized ?

Like PlayerInfo[playerid][pXp] = 1.0, for exemple
Reply
#5

I found this;
Код:
Player[playerid][pX]  = 0
under the enum of the ClearChar
Reply
#6

Not more ? Else, it's why the player is teleported to 0.0 0.0 0.0.

SetPlayerPos(i, Player[i][pXp], Player[i][pY], Player[i][pZ]);
You call variable "Player[i][pXp]" but he is initialized to 0.0, where is the problem ? You have no bugs, just stupidity.
Reply
#7

Quote:
Originally Posted by YouServ
Посмотреть сообщение
Not more ? Else, it's why the player is teleported to 0.0 0.0 0.0.

SetPlayerPos(i, Player[i][pXp], Player[i][pY], Player[i][pZ]);
You call variable "Player[i][pXp]" but he is initialized to 0.0, where is the problem ? You have no bugs, just stupidity.
It's called pX, not pXp, and stupidity? Did you learn fast? So you were stupid that time you were still learning.

Can you tell me what to do now? And I want to be teleported back to the same coords where he was when he did /joinevent.

Код:
IRP:joinevent(playerid, var[])
{
   	if(!Logged(playerid)) return NoLogin(playerid);
   	if(Player[playerid][pEBanned]) return SendClientMessage(playerid, COLOR_GRAD2, "You are banned from joining events.");
   	if(IsPlayerTazed(playerid) && IsPlayerCuffed(playerid) && IsPlayerTied(playerid)) return SendClientMessage(playerid, COLOR_GRAD2, "You are not allowed to join events at the moment");
   	if(Player[playerid][pDead]) return SendClientMessage(playerid, COLOR_GRAD2, "You are not allowed to join the event while you are injured.");
    if(Event[playerid]) return SendClientMessage(playerid, COLOR_GRAD2, "You are already in the event.");
	if(!EventOn) return SendClientMessage(playerid, COLOR_GRAD2, "There's no current event happening.");
	if(EventLocked) return SendClientMessage(playerid, COLOR_GRAD2, "The event is locked, be faster next time.");
	if(EventType == 1)
	{
	    Player[playerid][pInt] = GetPlayerInterior(playerid);
    	Player[playerid][pVW] = GetPlayerVirtualWorld(playerid);
    	GetPlayerPos(playerid, Player[playerid][pX], Player[playerid][pY], Player[playerid][pZ]);
    	GetPlayerHealth(playerid, Player[playerid][pHealth]);
    	GetPlayerArmour(playerid, Player[playerid][pArmor]);
    	SetPlayerPos(playerid, ePos[0], ePos[1], ePos[2]);
    	SetPlayerInterior(playerid, eInt);
    	SetPlayerVirtualWorld(playerid, eVW);
    	for(new i=0; i<13; i++)
    	{
	    	GetPlayerWeaponData(playerid, i, Player[playerid][pWeapon][i], Player[playerid][pWeaponAmmo][i]);
    	}
    	GunsBeingRemoved[playerid] = 1;
    	ResetPlayerWeapons(playerid);
    	Event[playerid] = 1;
    	SendClientMessage(playerid, COLOR_LIGHTRED, "** Please wait until the event starts and you will recieve everything set by the organizer.");
    	SendClientMessage(playerid, COLOR_LIGHTRED, "** Your original health, armor and weapons will be refunded once you leave the event, /quitevent to leave at any time.");
    }
    else if(EventType == 2)
	{
		Player[playerid][pColor] = GetPlayerColor(playerid);
		Player[playerid][pModel] = GetPlayerSkin(playerid);
	    Player[playerid][pInt] = GetPlayerInterior(playerid);
    	Player[playerid][pVW] = GetPlayerVirtualWorld(playerid);
    	GetPlayerPos(playerid, Player[playerid][pX], Player[playerid][pY], Player[playerid][pZ]);
    	GetPlayerHealth(playerid, Player[playerid][pHealth]);
    	GetPlayerArmour(playerid, Player[playerid][pArmor]);
    	SetPlayerPos(playerid, ePos[0], ePos[1], ePos[2]);
    	SetPlayerInterior(playerid, eInt);
    	SetPlayerVirtualWorld(playerid, eVW);
    	for(new i=0; i<13; i++)
    	{
	    	GetPlayerWeaponData(playerid, i, Player[playerid][pWeapon][i], Player[playerid][pWeaponAmmo][i]);
    	}
    	GunsBeingRemoved[playerid] = 1;
    	ResetPlayerWeapons(playerid);
    	Event[playerid] = 1;
    	new rr = random(2);
        if(rr == 1)
        {
            SetPlayerSkin(playerid, 230);
            EventTeam[playerid] = 1;
        }
        else if(rr == 2)
        {
            SetPlayerSkin(playerid, 137);
            EventTeam[playerid] = 2;
        }
    	SendClientMessage(playerid, COLOR_LIGHTRED, "** Please wait until the event starts and you will recieve everything set by the organizer.");
    	SendClientMessage(playerid, COLOR_LIGHTRED, "** Your original health, armor and weapons will be refunded once you leave the event, /quitevent to leave at any time.");
    	SendClientMessage(playerid, COLOR_LIGHTRED, "** Please stay at your team base till the event starts.");
    }
	return 1;
}
Give me explained steps what to give you and what to do.

P.S.: Read your PMs.
Reply
#8

Quote:
Originally Posted by KevinExec
Посмотреть сообщение
It's called pX, not pXp, and stupidity?
PHP код:
            SetPlayerPos(iPlayer[i][pXp], Player[i][pY], Player[i][pZ]); 
Yeah "pXp"

-----------------------------------------------------

PHP код:
// In /joinevent
GetPlayerPos(playeridPlayer[playerid][pX], Player[playerid][pY], Player[playerid][pZ]);
// In /endevent
SetPlayerPos(iPlayer[i][pXp], Player[i][pY], Player[i][pZ]); 
The X position is not same variable... "pX" ; "pXp"
Reply
#9

Alright let me adjust it. Thanks mate!

Read PMs please.

+REP for you.

EDIT: Doesn't work. What's the problem?
Reply
#10

PHP код:
IRP:endevent(playerid, var[])
{
       if(!
Logged(playerid)) return NoLogin(playerid);
    if(
Player[playerid][pAdmin] < 4) return NoAuth(playerid);
    if(!
EventOn) return SendClientMessage(playeridCOLOR_GRAD2"There's no current event happening.");
    
SendClientMessageToAll(COLOR_LIGHTRED"** The event has ended.");
    foreach(
Playeri) if(IsPlayerConnected(i))
    {
        if(
Event[i])
        {
            
GunsBeingRemoved[i] = 1;
            
ResetPlayerWeapons(i);
            
GunsBeingRemoved[playerid] = 1;
            
            
printf("[DEBUG SA-MP FORUM]: i : %d | pX : %f | pY : %f | pZ : %f"iPlayer[i][pX], Player[i][pY], Player[i][pZ]);
            
            
SetPlayerPos(iPlayer[i][pX], Player[i][pY], Player[i][pZ]);
            
SetPlayerInterior(iPlayer[i][pInt]);
            
SetPlayerVirtualWorld(iPlayer[i][pVW]);
            
SetPlayerHealth(iPlayer[i][pHealth]);
            
SetPlayerArmour(iPlayer[i][pArmor]);
            for(new 
013w++)
            {
                
GiveZamoraWeapon(iPlayer[i][pWeapon][w], Player[i][pWeaponAmmo][w]);
            }
            
Event[i] = 0;
        }
        
EventOn 0EventLocked 0;
        
ePos[0] = 0ePos[1] = 0ePos[2] = 0EventWep[0] = 0EventWep[1] = 0EventWep[2] = 0;
        
eInt 0eVW 0EventHealth 0EventArmor 0;
    }

    return 
1;

1. Connect you to the server
2. Try the command
3. Give me logs (server_logs.txt) line "[DEBUG SA-MP FORUM]: ..."
Reply


Forum Jump:


Users browsing this thread: