SA-MP Forums Archive
Hello need help with giverespect cmd.. - 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: Hello need help with giverespect cmd.. (/showthread.php?tid=473743)



Hello need help with giverespect cmd.. - Scrillex - 04.11.2013

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.


Re: Hello need help with giverespect cmd.. - AlonzoTorres - 04.11.2013

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;
}



Re: Hello need help with giverespect cmd.. - LeeXian99 - 04.11.2013

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!


Re: Hello need help with giverespect cmd.. - Scrillex - 04.11.2013

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;
}



Re: Hello need help with giverespect cmd.. - LeeXian99 - 04.11.2013

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.


Re: Hello need help with giverespect cmd.. - Scrillex - 04.11.2013

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

pawn Код:
error 036: empty statement



Re: Hello need help with giverespect cmd.. - Ballu Miaa - 04.11.2013

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;
}



Re: Hello need help with giverespect cmd.. - Scrillex - 04.11.2013

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


Re: Hello need help with giverespect cmd.. - Scrillex - 04.11.2013

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...


Re: Hello need help with giverespect cmd.. - Threshold - 04.11.2013

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)