AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   spawn, beginner (https://forums.alliedmods.net/showthread.php?t=207896)

leonardo_ 02-08-2013 00:10

spawn, beginner
 
How can I make it work?

I am a beginner, so don't judge me please... and help me...

I need like... If a person types "/spawn" in the chat he/she can spawn, but only 2 time per round, and I have no idea how to make it...

and look at my bad, really bad scripting: (:D)

PHP Code:

public plugin_init()

    
register_plugin("Vn""0.1""Alex")
    
register_clcmd("say /spawn","user_spawn")


PHP Code:

public user_spawn(id){
for(new 
02i++ )
    {
    
player players[i];
    if(
is_user_alive(player) && get_user_flags(player) & ADMIN_LEVEL_G)
    {
        
spawn(id)
    }
    }



simanovich 02-08-2013 01:26

Re: spawn, beginner
 
First, use Ham Sandwich spawn function. It better then using the fun function

(Note: Fakemeta dll-spawn is for entity, not for players - I checked at my server and it doesn't spawn me, but it show that i'm alive and no one can kill me).

You need to create a global variable that his size is 33 (32 cells, from 0 to 32)
And then read this: https://forums.alliedmods.net/showthread.php?t=42159

Use the round start event
There, use get_players (or just looping with get_maxplayers) and for every player reset the variable cell like that:
PHP Code:

for(new 1<= get_maxplayers(); i++) variable_name[i] = 0

Sorry i cann't help u more cuz i'm at school lol

leonardo_ 02-08-2013 01:31

Re: spawn, beginner
 
Quote:

Originally Posted by simanovich (Post 1889855)
First, use Ham Sandwich spawn function. It better then using the fun function

(Note: Fakemeta dll-spawn is for entity, not for players - I checked at my server and it doesn't spawn me, but it show that i'm alive and no one can kill me).

You need to create a global variable that his size is 33 (32 cells, from 0 to 32)
And then read this: https://forums.alliedmods.net/showthread.php?t=42159

Use the round start event
There, use get_players (or just looping with get_maxplayers) and for every player reset the variable cell like that:
PHP Code:

for(new 1<= get_maxplayers(); i++) variable_name[i] = 0

Sorry i cann't help u more cuz i'm at school lol

yes, I just found out about that function! It's actually is much better then the other one.
Thank you!

I'll try to make something then post it here and yo tell me ether it works or not, ok? :)

simanovich 02-08-2013 02:00

Re: spawn, beginner
 
Quote:

Originally Posted by leonardo_ (Post 1889856)
yes, I just found out about that function! It's actually is much better then the other one.
Thank you!

I'll try to make something then post it here and yo tell me ether it works or not, ok? :)

Compare you'r code with that code (I didn't test it, but it should work):
PHP Code:

#include <amxmodx>
#include <hamsandwich>

new g_SpawnTimes[33];
new 
g_MaxPlayers// It's just to reset

public plugin_init(){
    
register_clcmd("say /spawn","cmd_spawn");
    
    
register_event("HLTV""Event_NewRound""a""1=0""2=0");
    
    
g_MaxPlayers get_maxplayers(); // To reset the variable. there is another way with get_players
}

public 
Event_NewRound(){
    for (new 
1<= g_MaxPlayersi++)
        
g_SpawnTimes[i] = 0// Reset the variable cells to 0
}

public 
cmd_spawn(client){
    if (
g_SpawnTimes[client] > 2)
    {
        
client_print(client,print_chat,"[AMXX] You can respawn only 2 times per round"); // Message to client
        
return; // blocks the function so we won't respawn
    
}

    else if (
is_user_alive(client))
    {
        
client_print(client,print_chat,"[AMXX] Dude, you'r alive!");
        return;
    }
    
    
ExecuteHam(Ham_CS_RoundRespawn,client); // Respawn the client with Ham
    
client_print(client,print_chat,"[AMXX] You just respawned now lol"); // Send a message to client that he just respawned



leonardo_ 02-08-2013 02:11

Re: spawn, beginner
 
Quote:

Originally Posted by simanovich (Post 1889869)
Compare you'r code with that code (I didn't test it, but it should work):

PHP Code:

public plugin_init(){
    
register_clcmd("/spawn","cmd_spawn");
    
    
register_event("HLTV""Event_NewRound""a""1=0""2=0");
    
    
g_MaxPlayers get_maxplayers(); // To reset the variable. there is another way with get_players


->

PHP Code:

register_clcmd("say /spawn","cmd_spawn"); 

but yes, it works!

and what does that mean?

PHP Code:

register_event("HLTV""Event_NewRound""a""1=0""2=0"); 

that part:
PHP Code:

 "a""1=0""2=0"); 


simanovich 02-08-2013 02:45

Re: spawn, beginner
 
Quote:

Originally Posted by leonardo_ (Post 1889875)
PHP Code:

public plugin_init(){
    
register_clcmd("/spawn","cmd_spawn");
    
    
register_event("HLTV""Event_NewRound""a""1=0""2=0");
    
    
g_MaxPlayers get_maxplayers(); // To reset the variable. there is another way with get_players


->

PHP Code:

register_clcmd("say /spawn","cmd_spawn"); 

but yes, it works!

and what does that mean?

PHP Code:

register_event("HLTV""Event_NewRound""a""1=0""2=0"); 

that part:
PHP Code:

 "a""1=0""2=0"); 


About the first: Yap, I forgot to write "say"
About the second:
"a" is flag that says to amxx that it's a global event.
"1=0" means that the first param must be 0.
"2=0" means that the second param must be 0.

From amxmodx.inc:
PHP Code:

/* Registers event on which a given function will be called
* Flags:
* "a" - global event.
* "b" - specified.
* "c" - send only once when repeated to other players.
* "d" - call if is send to dead player.
* "e" - to alive.
* NOTE: Due to a long-standing bug that would break compatibility with old plugins,
*       the client id should be checked for alive/dead state if you use d or e.
* Examples for conditions:
* "2=c4" - 2nd parameter of message must be sting "c4".
* "3>10" - 3rd parameter must be greater then 10.
* "3!4" - 3rd must be different from 4.
* "2&Buy" - 2nd parameter of message must contain "Buy" substring.
* "2!Buy" - 2nd parameter of message can't contain "Buy" substring. */
native register_event(const event[],const function[],const flags[],const cond[]="", ... ); 



All times are GMT -4. The time now is 20:37.

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