hold off command?
#1

guys could somebody help me? i need to create a command that deattaches any attached object to player... but im a little noob in scripting... any help ? :S
Reply
#2

I'm on my phone so can't show an example. It wha you want to do is
Loop through all the players object slots then check in that loop if there is an object in that slot if yes destro it
Reply
#3

pawn Code:
CMD:removemyobjects(playerid, params[])
{    
    for(new ao; ao < 10; ao++)
    {
        if(IsPlayerAttachedObjectSlotUsed(playerid, ao))
        {
            RemovePlayerAttachedObject(playerid, ao);
        }
    }
    return 1;
}
Reply
#4

hmmm thx randy just a question... i dont use zcmd , i use a_samp include to script...so does a_samp support this script too?
Reply
#5

If you use no command plugin such as zcmd or ycmd then no this won't work. However I do recommend using a plugin such as those, it will make your life so much easier.
Reply
#6

I recommend you use ZCMD, however, a normal command that you will have to put under OnPlayerCommandText callback:

pawn Code:
if(!strcmp(cmdtext,"/removemyobjects", true)) // If the command submitted.
{
    for(new ao; ao < 10; ao++) // This loops through the ten slots, so all codes between the for braces will happen for the ten
    {
        if(IsPlayerAttachedObjectSlotUsed(playerid, ao))  // Checks if the slots are used.
        {
            RemovePlayerAttachedObject(playerid, ao); // If so remove the object(s).
        }
    }
    return 1;
}
Reply
#7

yeah but isn't a_samp good for a person who wants to start learning pawn language?
Reply
#8

a_samp
is requirde in order to make any script for samp!
not just a command processor
it has all other functions like: GiveMoney,Weather etc.
Reply
#9

a_samp isn't just for things like commands, it defines everything the the compiler/editor needs to know for the script to work. If you used to the syntax of pawn then I wouldn't worry too much and use ZCMD any way as the only thing the default method does it add unnecessary complications.
Reply
#10

well i scripted the beta version of my server by using a_samp ... ill try to create the next version with zcmd thx for helping guys
also ...
@Randy More : i tried your script...it compiled successfully but when i try this command...nothing works in game
Reply
#11

Like I said, if you are not using the plugin then the command will not work.
Reply
#12

yes it will just use this
pawn Code:
stock RemovePlayerAttachedObjects(playerid)
{
new numfound;
    for(new i=0; i<MAX_PLAYER_ATTACHED_OBJECTS; i++)
    {
        if(IsPlayerAttachedObjectSlotUsed(playerid, i)){
        RemovePlayerAttachedObject(playerid,i)
        numfound++;
        }
    }
return
}

//then later on use it like this(any where)
RemovePlayerAttachedObjects(playerid);

//also it can return how many objects were found example
new objects = RemovePlayerAttachedObjects(playerid);
printf("objects found: %d",objects);
Reply
#13

Edit: Fixed thanks so much guys also... +1 to park4bmx
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)