SA-MP Forums Archive
ID 0 to ID 1 and above - 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: ID 0 to ID 1 and above (/showthread.php?tid=378894)



ID 0 to ID 1 and above - kbalor - 19.09.2012

Script works but the problem is that If I'm the first one who connects to the server actually my ID is 0 or (ID:0)
then if someone join a player (ID:1) then I do /rep 1 it always say " You can't give yourself a reputation"

But when a Player 1 do /rep 0 It works! I received the rep.

What could be the problem??

pawn Код:
COMMAND:rep(playerid,params[])
{
    new repID, targetid, repName[MAX_PLAYER_NAME],name[24],str[128],str1[128];
    if(reptimer[playerid] > 0)
    {
        SendClientMessage(playerid, WHITE,"{FF0000}Please wait before using it again");
        return 1;
    }
    if(sscanf(params,"u",targetid))
    {
        SendClientMessage(playerid, WHITE,"{FFFF00}Usage: /rep [PlayerID]");
        return 1;
    }
    if(!IsPlayerConnected(targetid))
    {
        SendClientMessage(playerid, WHITE,"{FF0000}>>Player is not online");
        return 1;
    }
    if(repID == playerid)
    {
        SendClientMessage(playerid, WHITE,"{FF0000}>> You can't give yourself a reputation");
        return 1;
    }
    PlayerInfo[targetid][Reps]++;
    GetPlayerName(playerid,name,24);
    GetPlayerName(repID,repName,sizeof(repName));
    format(str,sizeof(str),"%s(%d) has gave +1 reputation point to you",name,playerid);
    SendClientMessage(targetid, GREEN,str);
    format(str1,sizeof(str1),"You have gave %s(%d) +1 reputation point",repName,repID);
    SendClientMessage(playerid, GREEN,str1);
    reptimer[playerid] = SetTimerEx("reptimer1",1200000,true,"i",playerid);
    return 1;
}



Re: ID 0 to ID 1 and above - RedJohn - 19.09.2012

pawn Код:
if(targetid == playerid)
    {
        SendClientMessage(playerid, WHITE,"{FF0000}>> You can't give yourself a reputation");
        return 1;
    }
Why are you using repID when you have targetid?

Full command.

pawn Код:
COMMAND:rep(playerid,params[])
{
    new targetid, repName[MAX_PLAYER_NAME],name[24],str[128],str1[128];
    if(reptimer[playerid] > 0) return SendClientMessage(playerid, WHITE,"{FF0000}Please wait before using it again");
    if(sscanf(params,"u",targetid)) return SendClientMessage(playerid, WHITE,"{FFFF00}Usage: /rep [PlayerID]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, WHITE,"{FF0000}>>Player is not online");
    if(targetid == playerid) return SendClientMessage(playerid, WHITE,"{FF0000}>> You can't give yourself a reputation");
    PlayerInfo[targetid][Reps]++;
    GetPlayerName(playerid,name,24);
    GetPlayerName(targetid,repName,sizeof(repName));
    format(str,sizeof(str),"%s(%d) has gave +1 reputation point to you",name,playerid);
    SendClientMessage(targetid, GREEN,str);
    format(str1,sizeof(str1),"You have gave %s(%d) +1 reputation point",repName,targetid);
    SendClientMessage(playerid, GREEN,str1);
    reptimer[playerid] = SetTimerEx("reptimer1",1200000,true,"i",playerid);
    return 1;
}



Re: ID 0 to ID 1 and above - kbalor - 19.09.2012

Quote:
Originally Posted by RedJohn
Посмотреть сообщение
pawn Код:
if(targetid == playerid)
    {
        SendClientMessage(playerid, WHITE,"{FF0000}>> You can't give yourself a reputation");
        return 1;
    }
Why are you using repID when you have targetid?

Full command.

pawn Код:
COMMAND:rep(playerid,params[])
{
    new targetid, repName[MAX_PLAYER_NAME],name[24],str[128],str1[128];
    if(reptimer[playerid] > 0) return SendClientMessage(playerid, WHITE,"{FF0000}Please wait before using it again");
    if(sscanf(params,"u",targetid)) return SendClientMessage(playerid, WHITE,"{FFFF00}Usage: /rep [PlayerID]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, WHITE,"{FF0000}>>Player is not online");
    if(targetid == playerid) return SendClientMessage(playerid, WHITE,"{FF0000}>> You can't give yourself a reputation");
    PlayerInfo[targetid][Reps]++;
    GetPlayerName(playerid,name,24);
    GetPlayerName(targetid,repName,sizeof(repName));
    format(str,sizeof(str),"%s(%d) has gave +1 reputation point to you",name,playerid);
    SendClientMessage(targetid, GREEN,str);
    format(str1,sizeof(str1),"You have gave %s(%d) +1 reputation point",repName,targetid);
    SendClientMessage(playerid, GREEN,str1);
    reptimer[playerid] = SetTimerEx("reptimer1",1200000,true,"i",playerid);
    return 1;
}
Wow thanks again for helping redjohn I was in hurry that time and kinda sleepy so I did not noticed. +REP my friend!


Re: ID 0 to ID 1 and above - RedJohn - 19.09.2012

Sorry for double post.

No problem. Does it working?