Help me with this, +rep if done.
#1

When i use /getgift in-game it says server unknown command. Also i need someone to modify as such that it's also gonna show how much time is left for the player to get a gift again.

Код:
#include<a_samp>
#include<zcmd>

new Random;

public OnFilterScriptInit()
{
      return 1;
}

public OnFilterScriptExit()
{
      return 1;
}

COMMAND:Getgift(playerid, params[])
{
    
     {
            Random = random(3);
            switch(Random)
            {
                  case 0: 
                  {
                          GivePlayerMoney(playerid, 200);
                          SendClientMessage(playerid, -1, "You opened a give and received $200.");
                  }
                  case 1: 
                  {
                          GivePlayerMoney(playerid, 500);
                          SendClientMessage(playerid, -1, "You opened a gift and received $500");
                  }
                  case 2: 
                  {       SetPlayerScore(playerid, GetPlayerScore(playerid)+2);
                          SendClientMessage(playerid, -1, "You opened a gift and received score.");
                  }
            }
            
     }
      SetTimerEx("EndGetgift", 10800000, true, "i", playerid);
     return 1;
}
forward EndGetgift(playerid);
 

public EndGetgift(playerid)
{

    return 1;
}
Reply
#2

PHP код:
#include            <a_samp>
#include                <streamer>
#include                <sscanf2>
#include            <zcmd>
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_RED 0xAA3333AA
 
#define MAX_RANDOM_GIFTS 3
 
public OnFilterScriptInit()
{
    print(
"\n--------------------------------------");
    print(
"Gift system by DrVenomous");
    print(
"--------------------------------------\n");
    return 
1;
}
 
#pragma tabsize 0
 
 
stock RandomGift(playerid)
{
    new 
randomgift random(MAX_RANDOM_GIFTS) + 1;
    switch (
randomgift)
    {
        case 
1:
        {
            
GivePlayerMoney(playerid50000);
                        
SendClientMessage(playeridCOLOR_YELLOW"You have won 50000$ enjoy!.");
        }
        case 
2:
        {
            
GivePlayerMoney(playerid10000);
                        
SendClientMessage(playeridCOLOR_YELLOW"You have won 10000$ enjoy!.");
        }
        case 
3:
        {
            
SetPlayerArmour(playerid100);
            
SendClientMessage(playeridCOLOR_YELLOW"You have a vest enjoy!.");
        }
    }
    return 
1;
}
 
 
new 
Float:giftPos[4];
new 
giftboxobject;
new 
giftboxcreated 0;
new 
Text3D:giftbox3DText;
 
 
CMD:giftbox(playeridparams[])
{
        if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1"You are not an admin!");
        if (
isnull(params))
        {
                
SendClientMessage(playerid, -1"/giftbox [Option]");
            
SendClientMessage(playeridCOLOR_YELLOW"[OPTIONS]: place, destroy");
                return 
1;
        }
        static
        
Float:X,
        
Float:Y,
        
Float:Z,
        
Float:A;
 
    
GetPlayerPos(playeridXYZ);
    
GetPlayerFacingAngle(playeridA);
 
        if (!
strcmp(params"place"true))
        {
            if (
IsPlayerInAnyVehicle(playerid))
                return 
SendClientMessage(playeridCOLOR_RED"You must be outside vehicle first.");
                if(
giftboxcreated == 1) return SendClientMessage(playeridCOLOR_RED"Giftbox is already placed.");
            
giftPos[0] = X;
            
giftPos[1] = Y;
            
giftPos[2] = Z;
            
giftboxcreated 1;
            
giftboxobject CreateDynamicObject(19054XY0.40.00.0A);
            
giftbox3DText CreateDynamic3DTextLabel("/getgift\nTo get your gift.",0x10F441AA,XYZ+0.25,8.0);
            
SendClientMessage(playerid, -1"You have placed a giftbox");
                        return 
1;
        }
       
        if (!
strcmp(params"destroy"true))
        {
     if(
giftboxcreated == 0) return SendClientMessage(playeridCOLOR_RED"Giftbox is not placed yet.");
            
DestroyDynamicObject(giftboxobject);
            
DestroyDynamic3DTextLabel(giftbox3DText);
            
giftboxcreated 0;
            
SendClientMessage(playerid, -1"You have destoryed the giftbox");
                        return 
1;
        }
        return 
1;
}
 
CMD:getgift(playerid)
{
        if(!
IsPlayerConnected(playerid))
            return 
SendClientMessage(playerid, -1"You must be logged in to do this.");
 
        
GetObjectPos(giftboxobjectgiftPos[0], giftPos[1], giftPos[2]);
       
        if(
IsPlayerInRangeOfPoint(playerid5.0giftPos[0], giftPos[1], giftPos[2]) && giftboxcreated == 1)
        {
        
RandomGift(playerid);
        }
        return 
1;

Try this, I used in my server and it worked
Reply
#3

Don't use the capital letter
Quote:

COMMAND:getgift(playerid, params[])

Instead of
Quote:

COMMAND:Getgift(playerid, params[])

It should work then.
Reply
#4

Quote:
Originally Posted by Ultraz
Посмотреть сообщение
Don't use the capital letter

Instead of

It should work then.
Are you sure, as well as the timer?
Reply
#5

Quote:
Originally Posted by Oxygenated
Посмотреть сообщение
Are you sure, as well as the timer?
They didn't mention the timer... Timer doesn't matter but the commands likely do.
Reply
#6

Not the answers, i was looking for, need someone to help with the timer still dosen't work
Reply
#7

PHP код:
#include<a_samp>
#include<zcmd>
public OnFilterScriptInit()
{
    return 
1;
}
public 
OnFilterScriptExit()
{
    return 
1;
}
new 
lastGift[MAX_PLAYERS];
COMMAND:getgift(playeridparams[])
{
    if(
gettime() < lastGift[playerid])
    {
        new 
str[128];
        new 
timeLeft lastGift[playerid] - gettime();
        
format(strsizeof(str), "You can get another gift in %d hours and %d minutes."timeLeft 60timeLeft 60);
        
SendClientMessage(playerid, -1str);
        return 
1;
    }
    switch(
random(3))
    {
        case 
0
        {
            
GivePlayerMoney(playerid200);
            
SendClientMessage(playerid, -1"You opened a give and received $200.");
        }
        case 
1
        {
            
GivePlayerMoney(playerid500);
            
SendClientMessage(playerid, -1"You opened a gift and received $500");
        }
        case 
2
        {   
SetPlayerScore(playeridGetPlayerScore(playerid)+2);
            
SendClientMessage(playerid, -1"You opened a gift and received score.");
        }
        
lastGift[playerid] = gettime() + 10800;
    }
    return 
1;

Give this a try.
Not tested.
Reply
#8

Finished with 4 errors guess you can fix

C:\Users\Karan\Desktop\Samp\pawno\include\zcmd.inc (96) : warning 217: loose indentation
C:\Users\Karan\Desktop\Samp\pawno\include\zcmd.inc (97) : warning 217: loose indentation
C:\Users\Karan\Desktop\Samp\pawno\include\zcmd.inc (9 : warning 217: loose indentation
C:\Users\Karan\Desktop\Samp\pawno\getgift02.pwn(46 ) : error 002: only a single statement (or expression) can follow each "case"
C:\Users\Karan\Desktop\Samp\pawno\getgift02.pwn(46 ) : error 029: invalid expression, assumed zero
C:\Users\Karan\Desktop\Samp\pawno\getgift02.pwn(46 ) : warning 215: expression has no effect
C:\Users\Karan\Desktop\Samp\pawno\getgift02.pwn(46 ) : error 001: expected token: ";", but found "]"
C:\Users\Karan\Desktop\Samp\pawno\getgift02.pwn(46 ) : fatal error 107: too many error messages on one line
Reply
#9

HELP HIM!
Reply
#10

The loose indentation warnings are because of the formatting.

I messed up by placing a statement outside a case within the switch statement.
Move the line lastGift[playerid] = gettime() + 10800; below the bracket out of the switch statement.

The correct code should look like this.

PHP код:
#include<a_samp> 
#include<zcmd> 
public OnFilterScriptInit() 

    return 
1

public 
OnFilterScriptExit() 

    return 
1

new 
lastGift[MAX_PLAYERS]; 
COMMAND:getgift(playeridparams[]) 

    if(
gettime() < lastGift[playerid]) 
    { 
        new 
str[128]; 
        new 
timeLeft lastGift[playerid] - gettime(); 
        
format(strsizeof(str), "You can get another gift in %d hours and %d minutes."timeLeft 60timeLeft 60); 
        
SendClientMessage(playerid, -1str); 
        return 
1
    } 
    switch(
random(3)) 
    { 
        case 
0:  
        { 
            
GivePlayerMoney(playerid200); 
            
SendClientMessage(playerid, -1"You opened a give and received $200."); 
        } 
        case 
1:  
        { 
            
GivePlayerMoney(playerid500); 
            
SendClientMessage(playerid, -1"You opened a gift and received $500"); 
        } 
        case 
2:  
        {   
SetPlayerScore(playeridGetPlayerScore(playerid)+2); 
            
SendClientMessage(playerid, -1"You opened a gift and received score."); 
        } 
    } 
    
lastGift[playerid] = gettime() + 10800
    return 
1

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)