/passcookie problems
#1

Hey guys im currently doing my custom cookie system for a server script im doing but the /passcookie won't give the other person the cookie or show there name on the me info

pawn Код:
CMD:passcookie(playerid,params[])
{
    new string[200],PID,Playername[MAX_PLAYER_NAME];
    GetPlayerName(PID, Playername, sizeof(Playername));
    if(PlayerInfo[playerid][pCookies] >=1)
    {
        if(sscanf(params, "s[128]", PID))
        {
            SendClientMessage(playerid,-1,"USAGE: /passcookie [playerid]");
        }
        else
        {
        format(string, sizeof(string), "* %s reaches into his pocket taking out a one big cookie passing it over to %s",RPName(playerid),RPName( PID ));
        ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        PlayerInfo[playerid][pCookies] --;
        PlayerInfo[PID][pCookies] ++;
        }
    }
    else
    {
        format(string, sizeof(string), "INFO:{3BB9FF} Sorry %s, Seams like you dont have any cookies", RPName(playerid));
        SendClientMessage(playerid,-1,string);

    }
    return 1;
}
Reply
#2

PHP код:
CMD:passcookie(playerid,params[])
{
    new 
string[128],PID,Playername[MAX_PLAYER_NAME];
    
GetPlayerName(PIDPlayernamesizeof(Playername));
    if(
PlayerInfo[playerid][pCookies] >=1)
    {
        if(
sscanf(params"d"PID)) return SendClientMessage(playerid,-1,"USAGE: /passcookie [playerid]");
        
format(stringsizeof(string), "* %s reaches into his pocket taking out a one big cookie passing it over to %s",RPName(playerid),RPNamePID ));
        
ProxDetector(20.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        
PlayerInfo[playerid][pCookies] --;
        
PlayerInfo[PID][pCookies] ++;
        }
    }
    else
    {
        
format(stringsizeof(string), "INFO:{3BB9FF} Sorry %s, Seams like you dont have any cookies"RPName(playerid));
        
SendClientMessage(playerid,-1,string);
    }
    return 
1;

samp chat line is maxed to 128 characters.
Also in the if-statement where your processing the user input your using a string (s) but you need an integer (i,d) you could also use the u parameter to find players
Reply
#3

First. You're getting the player name BEFORE getting its ID.
Second. You're only acceping a string. You should use 'u'.

Spoon feeding won't help you, try and fix the code yourself.
Reply
#4

Quote:
Originally Posted by TheDeadlyDutchi
Посмотреть сообщение
First. You're getting the player name BEFORE getting its ID.
didn't noticed xD
Reply
#5

@xerox8521 Not working
Reply
#6

pawn Код:
CMD:passcookie(playerid,params[])
{
    new string[128],PID,Playername[MAX_PLAYER_NAME];
    if(PlayerInfo[playerid][pCookies] >=1)
    {
        GetPlayerName(PID, Playername, sizeof(Playername));
        if(sscanf(params, "u", PID)) return SendClientMessage(playerid,-1,"USAGE: /passcookie [playerid]");
        format(string, sizeof(string), "* %s reaches into his pocket taking out a one big cookie passing it over to %s",RPName(playerid),RPName( PID ));
        ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        PlayerInfo[playerid][pCookies] --;
        PlayerInfo[PID][pCookies] ++;
    }
    else
    {
        format(string, sizeof(string), "INFO:{3BB9FF} Sorry %s, Seams like you dont have any cookies", RPName(playerid));
        SendClientMessage(playerid,-1,string);

    }
    return 1;
}
but why you entered
pawn Код:
new Playername[MAX_PLAYER_NAME];
if your using RPName stock?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)