Hello need help with giverespect cmd..
#1

Hello dear samp forum members.


So i want to let people use this cmd every one hour so it wouldn't be abused..

Here is the cmd and errors:

Errors
pawn Код:
error 001: expected token: ";", but found "-identifier-"
error 035: argument type mismatch (argument 1)
error 035: argument type mismatch (argument 1)
error 001: expected token: ")", but found ";"
error 036: empty statement
CODE:
pawn Код:
CMD:giverespect(playerid, params[])
{
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(CanUseCmd[playerid] == true)
    {
        new id, playerb[32], string[128];
        if(sscanf(params, "r", id)) return SendClientMessage(playerid, 0xCC0000AA, "USAGE: /respect <playerid/partofname>");
        PlayerInfo[playerid][pStreetRespect] ++
        PlayerInfo[playerid][pCMDT] = gettime();//error 001: expected token: ";", but found "-identifier-"
        if((gettime() - PlayerInfo[playerid][pCMDT]) < 3600000)
        CanUseCmd[playerid] = false;
        format(string, sizeof(string), " You have gived Street Respect to %s.", NORPN(playerb));//error 035: argument type mismatch (argument 1)
        SendClientMessage(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), " Player %s has gived you Street Respect to you.", NORPN(playerid));
        SendClientMessage(playerb, COLOR_WHITE, string);//  error 035: argument type mismatch (argument 1)
    }
    else if(PlayerInfo[playerid][pCMDT] < gettime(); //here last two errors...
    {
        CanUseCmd[playerid] = true;
    }
    return 1;
}
With best regards Scrillex.
Reply
#2

Try with this instead:

Quote:
Originally Posted by Scrillex
Посмотреть сообщение
pawn Код:
CMD:giverespect(playerid, params[])
{
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(CanUseCmd[playerid] == true)
    {
        new id, playerb[32], string[128];
        if(sscanf(params, "r", id)) return SendClientMessage(playerid, 0xCC0000AA, "USAGE: /respect <playerid/partofname>");
        PlayerInfo[playerid][pStreetRespect]++;
        PlayerInfo[playerid][pCMDT] = gettime();//error 001: expected token: ";", but found "-identifier-"
        if((gettime() - PlayerInfo[playerid][pCMDT]) < 3600000)
        CanUseCmd[playerid] = false;
        format(string, sizeof(string), " You have gived Street Respect to %s.", NORPN(playerb));//error 035: argument type mismatch (argument 1)
        SendClientMessage(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), " Player %s has gived you Street Respect to you.", NORPN(playerid));
        SendClientMessage(id, COLOR_WHITE, string);//  error 035: argument type mismatch (argument 1)
    }
    else if(PlayerInfo[playerid][pCMDT] < gettime()); //here last two errors...
    {
        CanUseCmd[playerid] = true;
    }
    return 1;
}
Reply
#3

pawn Код:
CMD:giverespect(playerid, params[])
{
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(CanUseCmd[playerid] == true)
    {
        new id, playerb[32], string[128], name ;
        if(sscanf(params, "r", id)) return SendClientMessage(playerid, 0xCC0000AA, "USAGE: /respect <playerid/partofname>");
        GetPlayerName(id, playerb, sizeof(playerb));
        GetPlayerName(playerid, name, sizeof(name));
        PlayerInfo[playerid][pStreetRespect] ++;
        PlayerInfo[playerid][pCMDT] = gettime();//You forgot a semicolon at the "PlayerInfo[playerid][pStreetRespect] ++"
        if((gettime() - PlayerInfo[playerid][pCMDT]) < 3600000)
        CanUseCmd[playerid] = false;
        format(string, sizeof(string), " You have gived Street Respect to %s.", playerb);//Try to change it.
        SendClientMessage(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), " Player %s has gived you Street Respect to you.", playerid);
        SendClientMessage(id, COLOR_WHITE, string);//Try to change it.
    }
    else if(PlayerInfo[playerid][pCMDT] < gettime()); //You forgot to add another ")"
    {
        CanUseCmd[playerid] = true;
    }
    return 1;
}
What does NORPN means? If you can, remove NORPN and use GetPlayerName instead of this!
Untested, but 95%, it has no error. If still have errors, post here!
Reply
#4

Still two errors...

pawn Код:
error 035: argument type mismatch (argument 1)
error 036: empty statement
NORPN :

pawn Код:
stock NORPN(playerid)
{
    new astring[25];
    if(PlayerInfo[playerid][pHideOn] == 0)format(astring, sizeof(astring), "%s", RemoveUnderScore(playerid));
    else if(PlayerInfo[playerid][pHideOn] == 1)format(astring, sizeof(astring), "Anon");
    return astring;
}
Reply
#5

Alright, check back the
pawn Код:
"format(string, sizeof(string), " Player %s has gived you Street Respect to you.", playerid);
        SendClientMessage(playerb, COLOR_WHITE, string);//Try to change it.
Change to
pawn Код:
format(string, sizeof(string), " Player %s has gived you Street Respect to you.", playerid);
        SendClientMessage(id, COLOR_WHITE, string);//Try to change it.
My full code is edited tho.
Reply
#6

Error lines:
pawn Код:
else if(PlayerInfo[playerid][pCMDT] < gettime());
    {
        CanUseCmd[playerid] = true;
    }
Code:

pawn Код:
error 036: empty statement
Reply
#7

Change this
pawn Код:
else if(PlayerInfo[playerid][pCMDT] < gettime());
To
pawn Код:
else if(PlayerInfo[playerid][pCMDT] < gettime())
Also.. Try this..

pawn Код:
stock NORPN(playerid)
{
    new astring[25];
    if(PlayerInfo[playerid][pHideOn] == 0)
    format(astring, sizeof(astring), "%s", RemoveUnderScore(playerid));
    else if(PlayerInfo[playerid][pHideOn] == 1)
    format(astring, sizeof(astring), "Anon");
    return astring;
}
Reply
#8

Ahh that's how it is when you don't sleep well at night .. Thanks mate with best regards
Reply
#9

Sorry for bump.. but yeah there is another prob.. I can use it as much as I want.. but I wanted to set it if you use this command you can use it after an hour...
Reply
#10

pawn Код:
if((gettime() - PlayerInfo[playerid][pCMDT]) < 3600000)
Should be:
pawn Код:
if((gettime() - PlayerInfo[playerid][pCMDT]) > 3600)
Unix timestamps are recorded in seconds, rather than milliseconds like the native timers. In this case, if the current time is 1 hour (3600 seconds) greater than when the player last used the command, continue. Which translates to:
pawn Код:
if((gettime() - PlayerInfo[playerid][pCMDT]) > 3600)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)