Restoring last positions
#1

Hello Sa-Mp Brothers, I have a bit of a problem with my re-spawn command.
I want to do the thing when I spawn a player to restore his last position but I did not succeed can you bros help me with this command so sort it out Please ?

here is my command:

Код:
CMD:spawn(playerid, params[])
{
	if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
	if(IsPlayerConnected(playerid))
	{
  		if (PlayerInfo[playerid][pAdmin] >= 1)
		{
			new id,sendername[30],giveplayer[30],string[256];
			if(sscanf(params, "u", id)) return SCM(playerid,COLOR_WHITE,"{FF9900}Scrie: {cef0ac}/spawn <Name/Playerid>");
			{
				if(IsPlayerConnected(id))
    			{
				    if(id != INVALID_PLAYER_ID)
    				{
						GetPlayerName(id, giveplayer, sizeof(giveplayer));
						SpawnPlayer(id);
						GetPlayerName(playerid, sendername, sizeof(sendername));
 						format(string, sizeof(string), "* Admin %s has spawn-ed you.", sendername);
						SendClientMessage(id, COLOR_IN2, string);
						format(string, sizeof(string), "You have respawned %s.", giveplayer);
						SendClientMessage(playerid, COLOR_IN2, string);
						format(string, sizeof(string), "AdmCmd: %s has /spawn-ed %s.",sendername, giveplayer);
						ABroadCast(COLOR_ADMCMD,string,1);
						HLChat(COLOR_ADMCMD,string);
						return 1;
					}
				}
                else
                {
                    SCM(playerid,COLOR_WHITE,"{FFFFCC}Error: Player not connected.");
                }
			}
   		}
		else
		{
			SendClientMessage(playerid, COLOR_ERROR, AdminOnly);
		}
	}
	return 1;
}
Reply
#2

what is problem ? give more detail and what are you expecting to do with this command which last postion u want?
Reply
#3

For example x got stuck, when I'm using /spawn the player should respawn and then restore his last position before getting stuck
Reply
#4

just raise the z axis a little bit
like
PHP код:
CMD:spawn(playeridparams[])
{
    if(
gPlayerLogged[playerid] == 0) return SendClientMessage(playeridCOLOR_LIGHTRED"You need to login first.");
    if(
IsPlayerConnected(playerid))
    {
          if (
PlayerInfo[playerid][pAdmin] >= 1)
        {
            new 
id,sendername[30],giveplayer[30],string[256];
            if(
sscanf(params"u"id)) return SCM(playerid,COLOR_WHITE,"{FF9900}Scrie: {cef0ac}/spawn <Name/Playerid>");
            {
                if(
IsPlayerConnected(id))
                {
                    if(
id != INVALID_PLAYER_ID)
                    {
                        
GetPlayerName(idgiveplayersizeof(giveplayer));
                        
GetPlayerPos(idxyz); 
                                                
SetPlayerPos(idxyz+5);
                        
GetPlayerName(playeridsendernamesizeof(sendername));
                         
format(stringsizeof(string), "* Admin %s has spawn-ed you."sendername);
                        
SendClientMessage(idCOLOR_IN2string);
                        
format(stringsizeof(string), "You have respawned %s."giveplayer);
                        
SendClientMessage(playeridCOLOR_IN2string);
                        
format(stringsizeof(string), "AdmCmd: %s has /spawn-ed %s.",sendernamegiveplayer);
                        
ABroadCast(COLOR_ADMCMD,string,1);
                        
HLChat(COLOR_ADMCMD,string);
                        return 
1;
                    }
                }
                else
                {
                    
SCM(playerid,COLOR_WHITE,"{FFFFCC}Error: Player not connected.");
                }
            }
           }
        else
        {
            
SendClientMessage(playeridCOLOR_ERRORAdminOnly);
        }
    }
    return 
1;

Try it
Reply
#5

I get this errors:

C:\Users\SYSTEM32\GMRPG\gamemodes\MDG.pwn(26667) : error 017: undefined symbol "x"
C:\Users\SYSTEM32\GMRPG\gamemodes\MDG.pwn(2666 : error 017: undefined symbol "x"
Reply
#6

PHP код:
CMD:spawn(playeridparams[]) 

    if(
gPlayerLogged[playerid] == 0) return SendClientMessage(playeridCOLOR_LIGHTRED"You need to login first."); 
    if(
IsPlayerConnected(playerid)) 
    { 
          if (
PlayerInfo[playerid][pAdmin] >= 1
        { 
            new 
id,sendername[30],giveplayer[30],string[256]; 
            if(
sscanf(params"u"id)) return SCM(playerid,COLOR_WHITE,"{FF9900}Scrie: {cef0ac}/spawn <Name/Playerid>"); 
            { 
                if(
IsPlayerConnected(id)) 
                { 
                    if(
id != INVALID_PLAYER_ID
                    { 
                        new 
float:x,float:y,float:z;
                        
GetPlayerName(idgiveplayersizeof(giveplayer)); 
                        
GetPlayerPos(idxyz);  
                                                
SetPlayerPos(idxyz+5); 
                        
GetPlayerName(playeridsendernamesizeof(sendername)); 
                         
format(stringsizeof(string), "* Admin %s has spawn-ed you."sendername); 
                        
SendClientMessage(idCOLOR_IN2string); 
                        
format(stringsizeof(string), "You have respawned %s."giveplayer); 
                        
SendClientMessage(playeridCOLOR_IN2string); 
                        
format(stringsizeof(string), "AdmCmd: %s has /spawn-ed %s.",sendernamegiveplayer); 
                        
ABroadCast(COLOR_ADMCMD,string,1); 
                        
HLChat(COLOR_ADMCMD,string); 
                        return 
1
                    } 
                } 
                else 
                { 
                    
SCM(playerid,COLOR_WHITE,"{FFFFCC}Error: Player not connected."); 
                } 
            } 
           } 
        else 
        { 
            
SendClientMessage(playeridCOLOR_ERRORAdminOnly); 
        } 
    } 
    return 
1

he forgot to define the floats
Reply
#7

And again another 7 warnings sorry brothers for making you think and kill your nerves with my stupid command

Код:
C:\Users\SYSTEM32\GMRPG\gamemodes\MDG.pwn(26668) : warning 213: tag mismatch
C:\Users\SYSTEM32\GMRPG\gamemodes\MDG.pwn(26668) : warning 213: tag mismatch
C:\Users\SYSTEM32\GMRPG\gamemodes\MDG.pwn(26668) : warning 213: tag mismatch
C:\Users\SYSTEM32\GMRPG\gamemodes\MDG.pwn(26669) : warning 213: tag mismatch
C:\Users\SYSTEM32\GMRPG\gamemodes\MDG.pwn(26669) : warning 213: tag mismatch
C:\Users\SYSTEM32\GMRPG\gamemodes\MDG.pwn(26669) : warning 213: tag mismatch
C:\Users\SYSTEM32\GMRPG\gamemodes\MDG.pwn(26687) : warning 217: loose indentation
Here are lines:

Код:
(26668) GetPlayerPos(id, x, y, z);
Код:
(26669) SetPlayerPos(id, x, y, z+5);
Код:
(26687)         else
        {
            SendClientMessage(playerid, COLOR_ERROR, AdminOnly);
        }
    }
    return 1;
}
Reply
#8

Anyone?
Reply
#9

Quote:
Originally Posted by Digii
Посмотреть сообщение
Anyone?
sorry i forgot the declaration and justjamie did float: i think its Float:

like this

PHP код:
CMD:spawn(playeridparams[])  
{  
    if(
gPlayerLogged[playerid] == 0) return SendClientMessage(playeridCOLOR_LIGHTRED"You need to login first.");  
    if(
IsPlayerConnected(playerid))  
    {  
          if (
PlayerInfo[playerid][pAdmin] >= 1)  
        {  
            new 
id,sendername[30],giveplayer[30],string[256];  
            if(
sscanf(params"u"id)) return SCM(playerid,COLOR_WHITE,"{FF9900}Scrie: {cef0ac}/spawn <Name/Playerid>");  
            {  
                if(
IsPlayerConnected(id))  
                {  
                    if(
id != INVALID_PLAYER_ID)  
                    {  
                        new 
Float:x,Float:y,Float:z
                        
GetPlayerName(idgiveplayersizeof(giveplayer));  
                        
GetPlayerPos(idxyz);   
                                                
SetPlayerPos(idxyz+5);  
                        
GetPlayerName(playeridsendernamesizeof(sendername));  
                         
format(stringsizeof(string), "* Admin %s has spawn-ed you."sendername);  
                        
SendClientMessage(idCOLOR_IN2string);  
                        
format(stringsizeof(string), "You have respawned %s."giveplayer);  
                        
SendClientMessage(playeridCOLOR_IN2string);  
                        
format(stringsizeof(string), "AdmCmd: %s has /spawn-ed %s.",sendernamegiveplayer);  
                        
ABroadCast(COLOR_ADMCMD,string,1);  
                        
HLChat(COLOR_ADMCMD,string);  
                        return 
1;  
                    }  
                }  
                else  
                {  
                    
SCM(playerid,COLOR_WHITE,"{FFFFCC}Error: Player not connected.");  
                }  
            }  
           }  
        else  
        {  
            
SendClientMessage(playeridCOLOR_ERRORAdminOnly);  
        }  
    }  
    return 
1;  

Reply
#10

Thank you Sreyas very much , thank all of you bros again <3.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)