SA-MP Forums

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

 
 
Thread Tools Display Modes
Old 07/11/2010, 03:20 AM   #1
willsuckformoney
High-roller
 
willsuckformoney's Avatar
 
Join Date: Dec 2009
Posts: 1,505
Reputation: 65
Default sscanf2 issue

How to fix this? It only works for one person.

pawn Code:
dcmd_wank(playerid,params[])
{
    new string[128],ID,aName[MAX_PLAYER_NAME],Name[MAX_PLAYER_NAME],Float:x,Float:y,Float:z;
    GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerName(ID,aName,sizeof(aName));
    GetPlayerPos(playerid,x,y,z);
    if(sscanf(params,"u",ID))
    {
        format(string,sizeof(string),"%s (%d) wanks on himself.",Name,playerid);
        SendClientMessageToAll(white,string);
        ApplyAnimation(playerid,"PAULNMAC","wank_out",4.1,1,1,1,1,1,1);
    }
    else if(IsPlayerInRangeOfPoint(ID,5,x,y,z))
    {
        format(string,sizeof(string),"%s (%d) wanks on %s (%d).",Name,playerid,aName,ID);
        SendClientMessageToAll(white,string);
        ApplyAnimation(playerid,"PAULNMAC","wank_out",4.1,1,1,1,1,1,1);
    } else return SendClientMessage(playerid,red,"Player is not close enough");
    return 1;
}

http://tinypic.com/r/2r2napy/7
http://tinypic.com/r/xpd5cz/7
http://tinypic.com/r/147ade/7
http://tinypic.com/r/34t1swn/7
http://tinypic.com/r/jsehkx/7

Look at the ids, the names and the lists, the one that has otto twice in it was supposed to be backfire.
__________________
Fuck the system.

Last edited by willsuckformoney; 07/11/2010 at 03:54 AM.
willsuckformoney is offline  
Old 07/11/2010, 03:40 AM   #2
GaGlets(R)
Gangsta
 
GaGlets(R)'s Avatar
 
Join Date: Oct 2009
Posts: 931
Reputation: 3
Default Re: sscanf2 issue

Let me guesss - only for you?

ApplyAnimation(playerid - cange that to "ID" in second part.
GaGlets(R) is offline  
Old 07/11/2010, 03:43 AM   #3
willsuckformoney
High-roller
 
willsuckformoney's Avatar
 
Join Date: Dec 2009
Posts: 1,505
Reputation: 65
Default Re: sscanf2 issue

That's not it, one sec I take a screen and why would I wanna apply an animation to the person I am WANKING ON? The animation is like that because it applies for the player that types the command.
__________________
Fuck the system.
willsuckformoney is offline  
Old 07/11/2010, 04:05 AM   #4
GaGlets(R)
Gangsta
 
GaGlets(R)'s Avatar
 
Join Date: Oct 2009
Posts: 931
Reputation: 3
Default Re: sscanf2 issue

better use zcmd...
pawn Code:
dcmd_wank(playerid,params[])
{
    if(!IsPlayerConnected(playerid)) return 1;
    new string[128],ID,aName[MAX_PLAYER_NAME],Name[MAX_PLAYER_NAME],Float:x,Float:y,Float:z;
    GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerName(ID,aName,sizeof(aName));
    GetPlayerPos(playerid,x,y,z);
    if(sscanf(params,"u",ID))
    {
        format(string,sizeof(string),"%s (%d) wanks on himself.",Name,playerid);
        SendClientMessageToAll(white,string);
        ApplyAnimation(playerid,"PAULNMAC","wank_out",4.1,1,1,1,1,1,1);
    }
    if(!IsPlayerConnected(ID)) return SendClientMessage(playerid,red,"Invalid ID");
    if(IsPlayerInRangeOfPoint(ID,5,x,y,z))
    {
        format(string,sizeof(string),"%s (%d) wanks on %s (%d).",Name,playerid,aName,ID);
        SendClientMessageToAll(white,string);
        ApplyAnimation(playerid,"PAULNMAC","wank_out",4.1,1,1,1,1,1,1);
        // thoug there is needed animation for player `ID`
    } else return SendClientMessage(playerid,red,"Player is not close enough");
    return 1;
}
this should work.
GaGlets(R) is offline  
Old 07/11/2010, 04:15 AM   #5
willsuckformoney
High-roller
 
willsuckformoney's Avatar
 
Join Date: Dec 2009
Posts: 1,505
Reputation: 65
Default Re: sscanf2 issue

pawn Code:
if(!IsPlayerConnected(playerid)) return 1;
That says if they are not connected, allow it.
__________________
Fuck the system.
willsuckformoney is offline  
Old 07/11/2010, 04:19 AM   #6
GaGlets(R)
Gangsta
 
GaGlets(R)'s Avatar
 
Join Date: Oct 2009
Posts: 931
Reputation: 3
Default Re: sscanf2 issue

let me explane something

playerid = player who types the command
ID - its in your sscanf

So first of all

pawn Code:
if(!IsplayerConnected(playerid)) return 1;
// that would check if typer is connected or check if it is not a bot. or something like that.
! - means not. so if not connected.

you were making `elsle if` after sscanf and then `else` would never work.
GaGlets(R) is offline  
Old 08/11/2010, 02:10 PM   #7
Nomine
Little Clucker
 
Join Date: Jan 2009
Posts: 3
Reputation: 0
Default Re: sscanf2 issue

Your problem is that you use GetPlayerName on ID before you find out what ID is.
That means when you use "GetPlayerName(ID,aName,sizeof(aName));" ID is still new, uninitialised, aka 0.
So the name will always be the name of player 0.

pawn Code:
dcmd_wank(playerid,params[])
{
    new ID; <-- ID is empty which means 0
    ...
    GetPlayerName(ID,aName,sizeof(aName)); <-- ID is still 0
    ...
    if(sscanf(params,"u",ID)) <-- This is where you find out what ID is
    {
        ...
    }
    ...
    return 1;
}
Nomine is offline  
Old 09/11/2010, 12:32 AM   #8
GaGlets(R)
Gangsta
 
GaGlets(R)'s Avatar
 
Join Date: Oct 2009
Posts: 931
Reputation: 3
Default Re: sscanf2 issue

Quote:
Originally Posted by Nomine View Post
Your problem is that you use GetPlayerName on ID before you find out what ID is.
That means when you use "GetPlayerName(ID,aName,sizeof(aName));" ID is still new, uninitialised, aka 0.
So the name will always be the name of player 0.

pawn Code:
dcmd_wank(playerid,params[])
{
    new ID; <-- ID is empty which means 0
    ...
    GetPlayerName(ID,aName,sizeof(aName)); <-- ID is still 0
    ...
    if(sscanf(params,"u",ID)) <-- This is where you find out what ID is
    {
        ...
    }
    ...
    return 1;
}
Uhm.. Ahm.. ehm..
pawn Code:
dcmd_wank(playerid,params[])
{
    new string[128],ID,aName[MAX_PLAYER_NAME],Name[MAX_PLAYER_NAME],Float:x,Float:y,Float:z;
    GetPlayerName(playerid,Name,sizeof(Name));
    GetPlayerPos(playerid,x,y,z);
    if(sscanf(params,"u",ID))
    GetPlayerName(ID,aName,sizeof(aName));
I cant see there something about what you wrote.

FAIL?
HAHAHAHAHAAAaaaaaaaa oftopicer
GaGlets(R) is offline  
Old 09/11/2010, 12:40 AM   #9
willsuckformoney
High-roller
 
willsuckformoney's Avatar
 
Join Date: Dec 2009
Posts: 1,505
Reputation: 65
Default Re: sscanf2 issue

ID is to take place for the player's ID....
__________________
Fuck the system.
willsuckformoney is offline  
Old 09/11/2010, 12:54 AM   #10
GaGlets(R)
Gangsta
 
GaGlets(R)'s Avatar
 
Join Date: Oct 2009
Posts: 931
Reputation: 3
Default Re: sscanf2 issue

Fail to in fact he was right

willsuck - you need to be more careful.

like i sed `!` means `NOT`
`playerid` player who types
`IsPlayerConnected(playerid)` If typer is connected
`!IsPlayerConnected(playerid)` if typer is NOT connected

Just follow this and your command will work.
pawn Code:
dcmd_wank(playerid,params[])
{
    if(!IsPlayerConnected(playerid)) return 1;
    new string[90],ID,aName[MAX_PLAYER_NAME],Name[MAX_PLAYER_NAME],Float:x,Float:y,Float:z;
    GetPlayerName(playerid,Name,sizeof(Name));
    GetPlayerPos(playerid,x,y,z);
    if(sscanf(params,"u",ID))
    {
        format(string,sizeof(string),"%s (%d) wanks on himself.",Name,playerid);
        SendClientMessageToAll(white,string);
        ApplyAnimation(playerid,"PAULNMAC","wank_out",4.1,1,1,1,1,1,1);
    }
    if(!IsPlayerConnected(ID)) return SendClientMessage(playerid,red,"Invalid ID");
    if(IsPlayerInRangeOfPoint(ID,5,x,y,z))
    {
        GetPlayerName(ID,aName,sizeof(aName));
        format(string,sizeof(string),"%s (%d) wanks on %s (%d).",Name,playerid,aName,ID);
        SendClientMessageToAll(white,string);
        ApplyAnimation(playerid,"PAULNMAC","wank_out",4.1,1,1,1,1,1,1);
        // thoug there is needed animation for player `ID`
    } else return SendClientMessage(playerid,red,"Player is not close enough");
    return 1;
}
GaGlets(R) is offline  
 

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
sscanf2 Hornet600 Help Archive 10 01/11/2010 04:26 PM
sscanf2 ihatetn931 Help Archive 0 21/09/2010 05:54 AM
Givecash with SSCANF2 LZLo Help Archive 6 27/08/2010 05:06 PM
[HELP] sscanf2.0 dcmd_crash Help Archive 6 17/06/2010 06:36 PM
Issue with sscanf2 and subcommands dcmd_crash Help Archive 1 13/05/2010 02:58 PM


All times are GMT. The time now is 08:51 PM.


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