SA-MP Forums Archive
Help Me. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help Me. (/showthread.php?tid=654297)



Help Me. - xRadical3 - 25.05.2018

I want to set object attach to player with a command and delete it with the same
What should I do?

PHP код:
CMD:vobj(playerid,params[])
{
    
SendClientMessage(playerid,0xFFF000AA,"Was Set!");
    
SetPlayerAttachedObject(playerid11869410, -0.390999, -0.387000, -1.716001, -26.399991, -4.099966, -166.099929);
    }
    
RemovePlayerAttachedObject(playerid1);
    return 
1;




Re: Help Me. - Lokii - 25.05.2018

PHP код:
static bool:attached[MAX_PLAYERS] = {false, ...};
public 
OnPlayerDisconnect(playerid)
{
    
attached[playerid] = false//reset on disconnect
    
return 1;
}
CMD:vobj(playerid,params[])
{
    if(!
attached[playerid]) //if not attached
    
{
        
SendClientMessage(playerid,0xFFF000AA,"Was Set!");
        
SetPlayerAttachedObject(playerid11869410, -0.390999, -0.387000, -1.716001, -26.399991, -4.099966, -166.099929);
        
attached[playerid] = true///set to true
    
}
    else
    {
        
RemovePlayerAttachedObject(playerid1);
        
attached[playerid] = false//set to false
    
}
    return 
1;




Re: Help Me. - xRadical3 - 25.05.2018

Quote:
Originally Posted by Lokii
Посмотреть сообщение
PHP код:
static bool:attached[MAX_PLAYERS] = {false, ...};
public 
OnPlayerDisconnect(playerid)
{
    
attached[playerid] = false//reset on disconnect
    
return 1;
}
CMD:vobj(playerid,params[])
{
    if(!
attached[playerid]) //if not attached
    
{
        
SendClientMessage(playerid,0xFFF000AA,"Was Set!");
        
SetPlayerAttachedObject(playerid11869410, -0.390999, -0.387000, -1.716001, -26.399991, -4.099966, -166.099929);
        
attached[playerid] = true///set to true
    
}
    else
    {
        
RemovePlayerAttachedObject(playerid1);
        
attached[playerid] = false//set to false
    
}
    return 
1;


Thank you