AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   New Code Error (https://forums.alliedmods.net/showthread.php?t=185287)

Waleed 05-15-2012 08:11

New Code Error
 
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <Hamsandwitch>



#define PLUGIN "SIMPLE HUD Message"
#define VERSION "1.0"
#define AUTHOR "Anonymouse"


public plugin_init() {
RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1)
}a

public fwHamPlayerSpawnPost(iPlayer) {
if (is_user_alive(iPlayer)) {
// player spawned
print_center("YOU ARE RE SPAWNED,GOODLUCK! FOR THIS TIME")
print_center("DON'T GET FUCKED UP THIS TIME,RETREAT HELL!!")
}
PLUGIN_HANDLED
}




Error: Cannot read from file: "Hamsandwitch" on line 5
What to do??
Will this code do anything??

<VeCo> 05-15-2012 08:13

Re: Error: Cannot read from file: "Hamsandwitch" on line 5
 
It's hamsandwich.

Also it should be:
PHP Code:

client_print(iPlayer,print_center,"your message here..."

Not just print_center.

Waleed 05-15-2012 08:26

Re: Error: Cannot read from file: "Hamsandwitch" on line 5
 
client_print(print_center "My message")

Error: Expected token: ",", but found "-string-" on line 23

If I add "ID",It says error about id...

what to do now ?

Waleed 05-15-2012 08:38

Script Compiled,But Now working
 
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>



#define PLUGIN "SIMPLE HUD Message"
#define VERSION "1.0"
#define AUTHOR "Anonymouse"


public plugin_init()
{
RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1)
}

public fwhamplayerspawnpost(iplayer){
if (is_user_alive(iplayer))
{

client_print(iplayer,print_center,"YOU ARE RE SPAWNED,GOODLUCK! FOR THIS TIME")
client_print(iplayer,print_center,"DON'T GET FUCKED UP THIS TIME,RETREAT HELL!!")

}

else {

client_print(iplayer,print_center,"SCREWYOU,Y OU'RE DEAD AGAIN")
client_print(iplayer,print_center,"WAIT FOR RE-SPAWN")
}
}



I have compiled this script with no errors but its not working.
My plan was to show a message on respawn and on death,But not working.
Any suggestions,This is my first simple plugin,Help please..........

hornet 05-15-2012 08:40

Re: Error: Cannot read from file: "Hamsandwitch" on line 5
 
There's no point in putting the else and the part after it, it will only cause errors.

PHP Code:

#include <amxmodx>
#include <hamsandwich>

#define PLUGIN "SIMPLE HUD Message"
#define VERSION "1.0"
#define AUTHOR "Anonymouse"

public plugin_init() 
{
    
RegisterHamHam_Spawn"player""fwHamPlayerSpawnPost");
}

public 
fwHamPlayerSpawnPostiPlayer 
{
    if( 
is_user_aliveiPlayer ) ) 
    {
        
// player spawned
        
client_printiPlayerprint_center"YOU ARE RE SPAWNED, GOODLUCK! FOR THIS TIME" );
        
client_printiPlayerprint_center"DON'T GET FUCKED UP THIS TIME, RETREAT HELL!!" );
    }



fysiks 05-16-2012 03:33

Re: Error: Cannot read from file: "Hamsandwitch" on line 5
 
Please learn to use [CODE][/CODE] tags around your code when posting.

Devil259 05-16-2012 08:02

Re: Error: Cannot read from file: "Hamsandwitch" on line 5
 
In Ham_Spawn hooked as post, if the player is not alive, that means he's connecting (loading).

hornet 05-16-2012 08:07

Re: Error: Cannot read from file: "Hamsandwitch" on line 5
 
Quote:

Originally Posted by Devil259 (Post 1709875)
In Ham_Spawn hooked as post, if the player is not alive, that means he's connecting (loading).

Aha! I've been looking for that answer for while :) I wondered why it caused errors if you didn't check if the player is alive.

Waleed 05-16-2012 08:39

New Code
 
I have changed the code,But still it isn't displaying anything,Any mistake here?

Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <Hamsandwich>

#define PLUGIN "HUD-Message"
#define VERSION "1.0"
#define AUTHOR "Waleed Baig"


public plugin_init() {
        register_plugin(PLUGIN, VERSION, AUTHOR)
        RegisterHam(Ham_Spawn,"players","fwhamplayerspawnpost",1)
       
}
public fwhamplayerspawnpost(iplayer)
{

 if (is_user_alive(iplayer))
{       
        set_hudmessage(0, 0, 255,0.5,0.5,0,6.0,30,0.5,0.5,4)
        show_hudmessage(iplayer, "I AM TRYING TO SHOW THIS MESSAGE")
       
}
}


hornet 05-16-2012 09:07

Re: New Code Error
 
It's because you changed the entity name for the hook, which will be erroring ... Change it back to what I showed you.

You need to change:

PHP Code:

RegisterHam(Ham_Spawn,"players","fwhamplayerspawnpost",1

To :arrow:

PHP Code:

RegisterHam(Ham_Spawn,"player","fwhamplayerspawnpost",1

And for a better message:

Change:

PHP Code:

set_hudmessage(00255,0.5,0.5,0,6.0,30,0.5,0.5,4

To :arrow:

PHP Code:

set_hudmessage(00255,-1.0,0.25,0,6.0,30,0.5,0.5

And PLEASE stop using those [CODE] tags use [PHP] tags!!


All times are GMT -4. The time now is 00:21.

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