Create- and DestroyObject.
#4

Quote:
Originally Posted by Backwardsman97
Посмотреть сообщение
Well if you declare the variable a in the command, it's scope will be limited to that command. You would need something like a PVar.

pawn Код:
if(!strcmp(cmd, "/plant", true))
{
    if(GetPVarInt(playerid,"WeedID") != -1)
    {
        //They already planted one
        return 1;
    }
    new
        Float:X,
        Float:Y,
        Float:Z,
        Float:A;
       
    GetPlayerFacingAngle(playerid,A);
    GetPlayerPos(playerid, X, Y, Z);
   
    X += (4 * floatsin(-A, degrees));
    Y += (4 * floatcos(-A, degrees));
   
    SetPVarInt(playerid,"WeedID",CreateObject(688, X, Y, Z, 0.0, 0.0, 96.0));
    return 1;
}
if(!strcmp(cmd, "/pickweed", true))
{
    if(GetPVarInt(playerid,"WeedID") == -1)
    {
        //They haven't planted one
        return 1;
    }
    DestroyObject(GetPVarInt(playerid,"WeedID"));
    SetPVarInt(playerid,"WeedID",-1);
    //Rest of your pick weed code
    return 1;
}
Hmm... I'd like to use this but i never paid attention to PVar, so i don't exactly know how
that works. And what do you exactly mean with the -1, can it just be 10 or something?
Reply


Messages In This Thread
Create- and DestroyObject. - by Ihsan-Cingisiz - 28.01.2011, 18:07
Re: Create- and DestroyObject. - by Kwarde - 28.01.2011, 18:10
Re: Create- and DestroyObject. - by Backwardsman97 - 28.01.2011, 18:15
Re: Create- and DestroyObject. - by Ihsan-Cingisiz - 28.01.2011, 20:38
Re: Create- and DestroyObject. - by Ihsan-Cingisiz - 28.01.2011, 20:45
Re: Create- and DestroyObject. - by Kasis - 28.01.2011, 20:49
Re: Create- and DestroyObject. - by Kwarde - 29.01.2011, 07:45
Re: Create- and DestroyObject. - by Ihsan-Cingisiz - 29.01.2011, 08:17

Forum Jump:


Users browsing this thread: 1 Guest(s)