Raised This Month: $51 Target: $400
 12% 

Again: PrintToChatAll


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tfs
Junior Member
Join Date: Jul 2013
Old 08-09-2013 , 14:15   Again: PrintToChatAll
Reply With Quote #1

Hi,

iam going to write a little plugin and got ready with everything but this cmd costs me now over an hour of searching and testing.
How the f**k do i use this? Everytime i get a JavaException: PrintToChatAll is not defined

Here my codesnippet:
PHP Code:
function onGameFrame(){
        if(
optionLane == "Mid Only"){
            
cvForceGameMode.setInt(11);
        }else{
            
cvForceGameMode.setInt(1);
        }
        
PrintToChatAll (PREFIX +"Pick anything, you will always get Pudge2")

Reference: http://docs.sourcemod.net/api/index....ad=show&id=115

Thank you for your help

Last edited by tfs; 08-09-2013 at 14:17. Reason: Reference added
tfs is offline
abckrieger
Senior Member
Join Date: Oct 2012
Location: Germany
Old 08-09-2013 , 14:18   Re: Again: PrintToChatAll
Reply With Quote #2

%s string
%f float
%i integer

PrintToChatAll ("%s Pick anything, you will always get Pudge2", PREFIX )
abckrieger is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 08-09-2013 , 14:21   Re: Again: PrintToChatAll
Reply With Quote #3

Quote:
Originally Posted by tfs View Post
PHP Code:
            cvForceGameMode.setInt(11);

Hi,

that doesn't look like valid Sourcepawn code to me.
And why on earth would you get a "JavaException" in Sourcemod ?
Makes no sense ? This is not Java. Did you try to run the plugin with java ?

String Concatenation doesn't work in Sourcepawn, use:

PrintToChatAll ("%s Pick anything, you will always get Pudge2", PREFIX)
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0

Last edited by berni; 08-09-2013 at 14:21.
berni is offline
tfs
Junior Member
Join Date: Jul 2013
Old 08-09-2013 , 14:26   Re: Again: PrintToChatAll
Reply With Quote #4

thank you but sorry my java isnt the best.... only got little knowlegde
still error, i tried it without the PREFIX long ago
here is the whole code:
PHP Code:
var optionLane 'Mid Only';
var 
PREFIX "\x099[PudgeWars] ";

game.hook("OnGameFrame"onGameFrame);
game.hook("OnMapStart"onMapStart);
game.hook("Dota_OnHeroPicked"onHeroPicked);

var 
cvForceGameMode console.findConVar("dota_force_gamemode");

var 
playermanager null;

var 
lobbyManager;


plugin.get('LobbyManager', function(obj){
    
lobbyManager obj;
    
optionHero lobbyManager.getOptionsForPlugin('MidOnly')['Hero'] || 'Any Hero';
});

function 
onMapStart(){
    
playermanager game.findEntityByClassname(-1"dota_player_manager");
}

function 
onGameFrame(){
        if(
optionLane == "Mid Only"){
            
cvForceGameMode.setInt(11);
        }else{
            
cvForceGameMode.setInt(1);
        }
        
PrintToChatAll ("%s Pick anything, you will always get Pudge2"PREFIX);
}
    
function 
onHeroPicked(clientclsname){
    return 
"npc_dota_hero_pudge";

Error:
PHP Code:
PudgeWars/Main.js:30Uncaught ReferenceErrorPrinToChatAll is not defined 
Additional note:
Because of my little knowlegde, i copy&paste around codesnippets of other plugins and testing like hell *duck and run*
Its a plugin for d2ware.net (DOTA2 Mods) - cvForceGameMode.setInt(1) is working as tested... and sorry it looked like java for me. my first time with sourcemod, just set it up today

Last edited by tfs; 08-09-2013 at 14:36.
tfs is offline
tfs
Junior Member
Join Date: Jul 2013
Old 08-09-2013 , 15:42   Re: Again: PrintToChatAll
Reply With Quote #5

ok i got a workaround with the following code:
PHP Code:
function getConnectedPlayingClients() {
    var 
clientplaying = [];
    for (var 
0server.clients.length; ++i)
    {
        
client server.clients[i];

        if (
client === null)
            continue;

        if (!
client.isInGame())
            continue;

        
playerID client.netprops.m_iplayerID;
        if (
playerID == -1)
            continue;

        
// if (getPlayerResource(playerID, "m_iConnectionState") !== 2)
        //     continue;

        
playing.push(client);
    }
    return 
playing;
}



function 
printToAll(string) {
    var 
iclientsclient;
    var 
clients getConnectedPlayingClients();
    for (
0clients.length; ++i)
    {
        
client clients[i];
        
client.printToChat("\x99[PudgeWars]" string);
    }

tfs is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 08-09-2013 , 17:05   Re: Again: PrintToChatAll
Reply With Quote #6

You are definitely not writing SourcePawn code, this is not the correct place to get support, and that is not the reference for the API you're using.
__________________
asherkin is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 15:58.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode