SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 14/07/2012, 06:43 AM   #1
rumen98
Huge Clucker
 
Join Date: Feb 2012
Posts: 293
Reputation: 14
Angry Have Problem please help

Hey people tried to do a check command but it did nothing to try it on another player shows my stats I need for an RP I'm doing
PHP Code:
CMD:check(playeridparams[])
{
    new 
gamer;
    new 
atext[128];
    new 
atext2[128];
    new 
nivo PlayerInfo[playerid][Hungry];
    new 
nivo2 PlayerInfo[gamer][Hungry];

    if(!
IsPlayerAdmin(playerid))
        return 
SendClientMessage(playeridCOLOR_RED" .");
    if (
sscanf(params"u"gamer)) SendClientMessage(playeridCOLOR_RED": \"/check <>");
    else if (
gamer == INVALID_PLAYER_IDSendClientMessage(playeridCOLOR_RED"   ");
    else
    {
        
format (atextsizeof(atext), "Hungry on player:%d",nivo);
        
format (atext2sizeof(atext2), "Hungry on player:%d",nivo2);
        
SendClientMessage(playeridCOLOR_PURPLEatext2);
        
SendClientMessage(playeridCOLOR_PURPLEatext);

    }
    return 
1;

rumen98 is offline   Reply With Quote
Old 14/07/2012, 09:34 AM   #2
AndreT
High-roller
 
AndreT's Avatar
 
Join Date: Jul 2011
Posts: 1,025
Reputation: 397
Default Re: Have Problem please help

Let me show you what you do here:
pawn Code:
new gamer;
new nivo2 = PlayerInfo[gamer][Hungry];

if(sscanf(params, "u", gamer)) // ...
The problem here is that you get the value of PlayerInfo[gamer][Hungry] before you even know what the gamer is supposed to be. So it always takes the Hungry value of player 0 (new variables are initialized with a 0 value).

What you need to do instead is:
pawn Code:
new gamer;
if(sscanf(params, "u", gamer))
{
    // ...
}
new nivo2 = PlayerInfo[gamer][Hungry];

This way, nivo2 will have a proper value.

Also what you do here:
pawn Code:
format (atext, sizeof(atext), "Hungry on player:%d",nivo);
format (atext2, sizeof(atext2), "Hungry on player:%d",nivo2);
SendClientMessage(playerid, COLOR_PURPLE, atext2);
SendClientMessage(playerid, COLOR_PURPLE, atext);
This uses 2 arrays to send these text lines, you could instead use only one:
pawn Code:
format(atext, sizeof(atext), "Hungry on player: %d", nivo);
SendClientMessage(playerid, COLOR_PURPLE, atext);
format(atext, sizeof(atext), "Hungry on player: %d", nivo2);
SendClientMessage(playerid, COLOR_PURPLE, atext);
AndreT is offline   Reply With Quote
Old 14/07/2012, 12:33 PM   #3
rumen98
Huge Clucker
 
Join Date: Feb 2012
Posts: 293
Reputation: 14
Default Re: Have Problem please help

Quote:
Originally Posted by AndreT View Post
Let me show you what you do here:
pawn Code:
new gamer;
new nivo2 = PlayerInfo[gamer][Hungry];

if(sscanf(params, "u", gamer)) // ...
The problem here is that you get the value of PlayerInfo[gamer][Hungry] before you even know what the gamer is supposed to be. So it always takes the Hungry value of player 0 (new variables are initialized with a 0 value).

What you need to do instead is:
pawn Code:
new gamer;
if(sscanf(params, "u", gamer))
{
    // ...
}
new nivo2 = PlayerInfo[gamer][Hungry];

This way, nivo2 will have a proper value.

Also what you do here:
pawn Code:
format (atext, sizeof(atext), "Hungry on player:%d",nivo);
format (atext2, sizeof(atext2), "Hungry on player:%d",nivo2);
SendClientMessage(playerid, COLOR_PURPLE, atext2);
SendClientMessage(playerid, COLOR_PURPLE, atext);
This uses 2 arrays to send these text lines, you could instead use only one:
pawn Code:
format(atext, sizeof(atext), "Hungry on player: %d", nivo);
SendClientMessage(playerid, COLOR_PURPLE, atext);
format(atext, sizeof(atext), "Hungry on player: %d", nivo2);
SendClientMessage(playerid, COLOR_PURPLE, atext);
thanks i will try it
rumen98 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I fixed the launching GTASA problem! Now the problem is in SAMP! HELP! Moustafa Client Support 24 16/09/2012 03:01 AM
Problem with time formatted message (or some other problem) CptK Scripting Help 0 02/06/2012 01:11 PM
Wanted problem and neon system problem iRealSAMP Scripting Help 4 04/02/2012 07:22 PM
Info Pickup problem [SOLVED] New problem now..... Juanxz Help Archive 2 22/01/2010 08:19 AM
problem with CWRP in linux (mysql problem) BSMan Server Support 1 16/06/2009 02:36 PM


All times are GMT. The time now is 08:04 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.